X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=src%2Fpdf2pdf.c;h=485c6c03693f8f7328012e2ac960bcddd7930712;hp=f642df6af0911f1991cf7fa3136911df99ebefa9;hb=f29d8006b1d8253c50808d6eb4941bdeb808c601;hpb=580c48fef10df9184cf2728338e89f7db0fef2f5 diff --git a/src/pdf2pdf.c b/src/pdf2pdf.c index f642df6..485c6c0 100644 --- a/src/pdf2pdf.c +++ b/src/pdf2pdf.c @@ -40,6 +40,8 @@ static gfxsource_t*driver = 0; +static int maxwidth = 0; +static int maxheight = 0; static char * outputname = 0; static int loglevel = 3; static char * pagerange = 0; @@ -93,13 +95,23 @@ int args_callback_option(char*name,char*val) { if(c && *c && c[1]) { *c = 0; c++; - driver->set_parameter(driver, s,c); + driver->setparameter(driver, s,c); } else { - driver->set_parameter(driver, s,"1"); + driver->setparameter(driver, s,"1"); } free(s); return 1; } + else if (!strcmp(name, "X")) + { + maxwidth = atoi(val); + return 1; + } + else if (!strcmp(name, "Y")) + { + maxheight = atoi(val); + return 1; + } else if (!strcmp(name, "V")) { printf("pdf2swf - part of %s %s\n", PACKAGE, VERSION); @@ -113,13 +125,16 @@ int args_callback_option(char*name,char*val) { return 0; } -struct options_t options[] = -{{"o","output"}, - {"q","quiet"}, - {"V","version"}, - {"s","set"}, - {"p","pages"}, - {0,0} +static struct options_t options[] = { +{"h", "help"}, +{"v", "verbose"}, +{"p", "pages"}, +{"X", "width"}, +{"Y", "height"}, +{"s", "set"}, +{"o", "output"}, +{"V", "version"}, +{0,0} }; int args_callback_longoption(char*name,char*val) { @@ -156,8 +171,20 @@ int args_callback_command(char*name, char*val) { return 0; } -void args_callback_usage(char*name) +void args_callback_usage(char *name) { + printf("\n"); + printf("Usage: %s \n", name); + printf("\n"); + printf("-h , --help Print short help message and exit\n"); + printf("-v , --verbose Be verbose. Use more than one -v for greater effect.\n"); + printf("-p , --pages Pages to convert\n"); + printf("-X , --width Make sure the output pdf is pixels wide\n"); + printf("-Y , --height Make sure the output pdf is pixels high\n"); + printf("-s , --set = Set to \n"); + printf("-o , --output Write output to file .\n"); + printf("-V , --version Print version info and exit\n"); + printf("\n"); } int main(int argn, char *argv[]) @@ -185,7 +212,7 @@ int main(int argn, char *argv[]) is_in_range(0x7fffffff, pagerange); if(pagerange) - driver->set_parameter(driver, "pages", pagerange); + driver->setparameter(driver, "pages", pagerange); if(!filename) { args_callback_usage(argv[0]); @@ -193,8 +220,8 @@ int main(int argn, char *argv[]) } gfxdocument_t* doc = driver->open(driver, filename); - doc->set_parameter(doc, "drawonlyshapes", "1"); - doc->set_parameter(doc, "disable_polygon_conversion", "1"); + //doc->setparameter(doc, "drawonlyshapes", "1"); + doc->setparameter(doc, "disable_polygon_conversion", "1"); if(!doc) { msg(" Couldn't open %s", filename); @@ -208,6 +235,13 @@ int main(int argn, char *argv[]) gfxdevice_removeclippings_init(&wrap, out); out = &wrap;*/ + gfxdevice_t rescale; + if(maxwidth || maxheight) { + gfxdevice_rescale_init(&rescale, out, maxwidth, maxheight, 0); + out = &rescale; + out->setparameter(out, "keepratio", "1"); + } + int pagenr; for(pagenr = 1; pagenr <= doc->num_pages; pagenr++) {