X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fpdf2swf.c;h=6a615718e2051bee7fb8823794f43adddf2c543e;hb=02324a6b804c8ba7bff6ca581a70b52d84b166e6;hp=48904e538f65a2ef9747fee73d27b9bef9ab1420;hpb=da91e3e4408443fcd917bee01022576b1ed7a904;p=swftools.git diff --git a/src/pdf2swf.c b/src/pdf2swf.c index 48904e5..6a61571 100644 --- a/src/pdf2swf.c +++ b/src/pdf2swf.c @@ -36,7 +36,7 @@ #include "../lib/rfxswf.h" #include "../lib/devices/swf.h" #include "../lib/devices/arts.h" -#include "../lib/xpdf/pdf.h" +#include "../lib/pdf/pdf.h" #include "../lib/log.h" #define SWFDIR concatPaths(getInstallationPath(), "swfs") @@ -55,6 +55,8 @@ static char * viewer = 0; static int xnup = 1; static int ynup = 1; +static int info_only = 0; + static int flatten = 0; char* fontpaths[256]; @@ -214,6 +216,11 @@ int args_callback_option(char*name,char*val) { driver->set_parameter("opennewwindow", "1"); return 0; } + else if (!strcmp(name, "I")) + { + info_only = 1; + return 0; + } else if (!strcmp(name, "t")) { driver->set_parameter("insertstop", "1"); @@ -343,6 +350,7 @@ struct options_t options[] = {"q","quiet"}, {"V","version"}, {"i","ignore"}, + {"I","info"}, {"z","zlib"}, {"s","set"}, {"S","shapes"}, @@ -439,6 +447,34 @@ float getRate(char*filename) return swf.frameRate / 256.0; } +void show_info(gfxsource_t*driver, char*filename) +{ + gfxdocument_t* pdf = driver->open(filename); + int pagenr; + FILE*fo=0; + if(!pdf) { + msg(" Couldn't open %s", filename); + exit(1); + } + if(outputname) { + fo = fopen(outputname, "wb"); + if(!fo) { + perror(outputname);exit(1);; + } + } else { + fo = stdout; + } + + for(pagenr = 1; pagenr <= pdf->num_pages; pagenr++) + { + gfxpage_t*page = pdf->getpage(pdf,pagenr); + if(is_in_range(pagenr, pagerange)) { + fprintf(fo, "page=%d width=%.2f height=%.2f\n", pagenr, page->width, page->height); + } + } + pdf->destroy(pdf); +} + int main(int argn, char *argv[]) { int ret; @@ -485,6 +521,11 @@ int main(int argn, char *argv[]) exit(1); } + if(info_only) { + show_info(driver, filename); + return 0; + } + if(!outputname) { if(filename) { @@ -588,9 +629,9 @@ int main(int argn, char *argv[]) int t = y*xnup + x; if(pages[t].page->width > xmax[x]) - xmax[x] = pages[t].page->width; + xmax[x] = (int)pages[t].page->width; if(pages[t].page->height > ymax[y]) - ymax[y] = pages[t].page->height; + ymax[y] = (int)pages[t].page->height; } for(x=0;x