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;
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);
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) {
return 0;
}
-void args_callback_usage(char*name)
+void args_callback_usage(char *name)
{
+ printf("\n");
+ printf("Usage: %s <pdffile>\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> Pages to convert\n");
+ printf("-X , --width <width> Make sure the output pdf is <width> pixels wide\n");
+ printf("-Y , --height <height> Make sure the output pdf is <height> pixels high\n");
+ printf("-s , --set <parameter>=<value> Set <parameter> to <value>\n");
+ printf("-o , --output <filename> Write output to file <filename>.\n");
+ printf("-V , --version Print version info and exit\n");
+ printf("\n");
}
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]);
}
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("<error> Couldn't open %s", filename);
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++)
{