X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;h=c943c691848a51ccf5c8262e0037c2f0811b0274;hb=3dab974276d6a99794e4dd33622a1dc098e4a27c;hp=739deb848e9da1b0d9d6c6c72802e7b5df81dbdd;hpb=11ad4fc1ce7b6582c8dbf1a99df89a1d5d25a0de;p=swftools.git diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index 739deb8..c943c69 100644 --- a/pdf2swf/pdf2swf.cc +++ b/pdf2swf/pdf2swf.cc @@ -33,9 +33,7 @@ #endif #include "../lib/args.h" #include "SWFOutputDev.h" -extern "C" { #include "log.h" -} #ifndef WIN32 #define FONTDIR SWFTOOLS_DATADIR "/fonts" @@ -132,40 +130,41 @@ int args_callback_option(char*name,char*val) { } else if (!strcmp(name, "S")) { - pdfswf_drawonlyshapes(); + pdfswf_setparameter("drawonlyshapes", "1"); return 0; } else if (!strcmp(name, "i")) { - pdfswf_ignoredraworder(); + pdfswf_setparameter("ignoredraworder", "1"); return 0; } else if (!strcmp(name, "z")) { - pdfswf_enablezlib(); + pdfswf_setparameter("enablezlib", "1"); return 0; } else if (!strcmp(name, "n")) { - pdfswf_linksopennewwindow(); + pdfswf_setparameter("opennewwindow", "1"); return 0; } else if (!strcmp(name, "t")) { - pdfswf_insertstop(); + pdfswf_setparameter("insertstop", "1"); return 0; } else if (!strcmp(name, "T")) { - int i = atoi(val); if(!strcasecmp(val, "mx")) - i = 6; - pdfswf_setversion(i); + pdfswf_setparameter("flashversion", "6"); + else + pdfswf_setparameter("flashversion", val); + return 1; } else if (!strcmp(name, "f")) { - pdfswf_storeallcharacters(); + pdfswf_setparameter("storeallcharacters", "1"); return 0; } else if (!strcmp(name, "F")) @@ -226,10 +225,10 @@ int args_callback_option(char*name,char*val) { else if (!strcmp(name, "j")) { if(name[1]) { - pdfswf_jpegquality(atoi(&name[1])); + pdfswf_setparameter("jpegquality", &name[1]); return 0; } else { - pdfswf_jpegquality(atoi(val)); + pdfswf_setparameter("jpegquality", val); return 1; } } @@ -317,18 +316,21 @@ void args_callback_usage(char*name) #endif printf("-V --version Print program version\n"); printf("\nEnhanced conversion options:\n"); - printf("-t --stop Insert a \"Stop\" Tag in every frame (don't turn pages automatically)\n"); printf("-S --shapes Don't use SWF Fonts, but store everything as shape\n"); printf("-z --zlib Use Flash 6 (MX) zlib compression (Needs at least Flash 6 Plugin to play)\n"); - printf("-j --jpegquality=quality Set quality of embedded jpeg pictures (default:85)\n"); printf("-w --samewindow Don't open a new Browser Window for Links in the SWF\n"); printf("-f --fonts Store full fonts in SWF. (Don't reduce to used characters)\n"); printf("-T --flashversion=num Set the flash version in the header to num (default: 4)\n"); + printf("-s insertstop Insert a \"Stop\" Tag in every frame (don't turn pages automatically)\n"); + printf("-s zoom=factor Scale result, default: 72\n"); + printf("-s jpegquality=quality Set quality of embedded jpeg pictures (default:85)\n"); printf("-s caplinewidth=value Set the minimum line width to trigger cap style handling to value. (3)\n"); printf("-s splinequality=value Set the quality of spline convertion to value (0-100, default: 100).\n"); printf("-s fontquality=value Set the quality of font convertion to value (0-100, default: 100).\n"); - printf("-s ignoredraworder Ignore draw order (makes the SWF file smaller, but may produce\n" + printf("-s ignoredraworder Ignore draw order (makes the SWF file smaller and faster, but may produce\n" " graphic errors)\n"); + printf("-s filloverlap Make intersecting shapes overlap, instead of canceling each\n" + " other out. (Needed for some Powerpoint PDFs)\n"); printf("Postprocessing options:\n"); #ifndef SYSTEM_BACKTICKS printf("(They might not work because your system call doesn't support command substitution)\n"); @@ -340,7 +342,7 @@ void args_callback_usage(char*name) } #ifdef HAVE_DIRENT_H -void addfontdir(char* dirname, int*numfonts) +static void addfontdir(char* dirname, int*numfonts) { if(!numfonts) msg(" Adding %s to search path\n", dirname); @@ -350,7 +352,7 @@ void addfontdir(char* dirname, int*numfonts) msg(" Couldn't open directory %s\n", dirname); return; } - dirent*ent; + struct dirent*ent; while(1) { ent = readdir (dir); if (!ent) @@ -389,7 +391,7 @@ void addfontdir(char* dirname, int*numfonts) } #endif -char* stripfilename(char*filename, char*newext) +static char* stripfilename(char*filename, char*newext) { char*last1 = strrchr(filename, '/'); char*last2 = strrchr(filename, '\\'); @@ -479,18 +481,29 @@ int main(int argn, char *argv[]) msg(" Couldn't find any fonts!"); #endif - pdfswf_init(filename, password); - pdfswf_setoutputfilename(outputname); + pdf_doc_t* pdf = pdf_init(filename, password); + if(!pdf) { + msg(" Couldn't open %s", filename); + exit(1); + } + swf_output_t* swf = swf_output_init(); - int pages = pdfswf_numpages(); - for(t = 1; t <= pages; t++) + for(t = 1; t <= pdf->num_pages; t++) { - if(is_in_range(t, pagerange)) - pdfswf_convertpage(t); + if(is_in_range(t, pagerange)) { + /* for links: FIXME */ + pdfswf_preparepage(t); + } + if(is_in_range(t, pagerange)) { + pdf_page_t*page = pdf_getpage(pdf, t); + pdf_page_render(page, swf); + pdf_page_destroy(page); + } } - pdfswf_performconversion(); + swf_output_save(swf, outputname); + swf_output_destroy(swf); - pdfswf_close(); + pdf_destroy(pdf); if(viewer || preloader) { #ifndef SYSTEM_BACKTICKS @@ -525,4 +538,3 @@ int main(int argn, char *argv[]) return 0; } -