X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=src%2Fpdf2swf.c;h=3b67bccbfd22341470273c7eb7966c70c3e66fbf;hp=4f82dfc11039b32d97d7e29f92317c7254801a3c;hb=f32de5188d6ec5a3b70ced18669e27e0b250bf50;hpb=6c8f037f0f76ce4b28b80a2133e4150d93012ef7 diff --git a/src/pdf2swf.c b/src/pdf2swf.c index 4f82dfc..3b67bcc 100644 --- a/src/pdf2swf.c +++ b/src/pdf2swf.c @@ -43,6 +43,7 @@ #include "../lib/devices/polyops.h" #include "../lib/devices/record.h" #include "../lib/devices/rescale.h" +#include "../lib/gfxfilter.h" #include "../lib/pdf/pdf.h" #include "../lib/log.h" @@ -71,6 +72,8 @@ static int max_time = 0; static int flatten = 0; +static char* filters = 0; + char* fontpaths[256]; int fontpathpos = 0; @@ -257,7 +260,7 @@ int args_callback_option(char*name,char*val) { } else if (!strcmp(name, "s")) { - char*s = strdup(val); + char*s = val; char*c = strchr(s, '='); if(c && *c && c[1]) { *c = 0; @@ -334,6 +337,20 @@ int args_callback_option(char*name,char*val) { store_parameter("extrafontdata", "1"); return 0; } + else if (!strcmp(name, "ff")) + { + if(filters) { + // append this to the current filter expression (we allow more than one --filter) + int l = strlen(filters); + int new_len = l + strlen(val) + 2; + filters = (char*)realloc(filters, new_len); + filters[l] = ':'; + strcpy(filters+l+1, val); + } else { + filters = strdup(val); + } + return 1; + } else if (!strcmp(name, "w")) { store_parameter("linksopennewwindow", "0"); @@ -454,6 +471,7 @@ static struct options_t options[] = { {"t", "stop"}, {"T", "flashversion"}, {"F", "fontdir"}, +{"ff", "filter"}, {"b", "defaultviewer"}, {"l", "defaultloader"}, {"B", "viewer"}, @@ -588,6 +606,16 @@ gfxdevice_t*create_output_device() out = &rescale; } + if(filters) { + gfxfilterchain_t*chain = gfxfilterchain_parse(filters); + if(!chain) { + fprintf(stderr, "Unable to parse filters: %s\n", filters); + exit(1); + } + out = gfxfilterchain_apply(chain, out); + gfxfilterchain_destroy(chain); + } + /* pass global parameters to output device */ parameter_t*p = device_config; while(p) { @@ -887,6 +915,9 @@ int main(int argn, char *argv[]) p->next = 0;free(p); p = next; } + if(filters) { + free(filters); + } return 0; }