X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;h=a47b91d94d1856a59d3ef7fc02df3345a6356f2e;hb=607c5dadd6089768b618cc99346de1b37a2c46f1;hp=0a624f02bef4cd59c5cbda9de10dad4b287153d8;hpb=be34d57438865353c7c3b0186e51fbc985e8a04a;p=swftools.git diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index 0a624f0..a47b91d 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" @@ -89,11 +87,13 @@ int args_callback_option(char*name,char*val) { else if (!strcmp(name, "v")) { loglevel ++; + setConsoleLogging(loglevel); return 0; } else if (!strcmp(name, "q")) { loglevel --; + setConsoleLogging(loglevel); system_quiet = 1; return 0; } @@ -132,40 +132,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 +227,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; } } @@ -323,7 +324,7 @@ void args_callback_usage(char*name) 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: 100 (before 0.6.2: 72)\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"); @@ -342,57 +343,7 @@ void args_callback_usage(char*name) printf("-L --preloader=filename Link preloader \"name\" to the pdf (\"%s -L\" for list)\n",name); } -#ifdef HAVE_DIRENT_H -void addfontdir(char* dirname, int*numfonts) -{ - if(!numfonts) - msg(" Adding %s to search path\n", dirname); - - DIR*dir = opendir(dirname); - if(!dir) { - msg(" Couldn't open directory %s\n", dirname); - return; - } - dirent*ent; - while(1) { - ent = readdir (dir); - if (!ent) - break; - int l; - char*name = ent->d_name; - char type = 0; - if(!name) continue; - l=strlen(name); - if(l<4) - continue; - if(!strncasecmp(&name[l-4], ".pfa", 4)) - type=1; - if(!strncasecmp(&name[l-4], ".pfb", 4)) - type=3; - if(!strncasecmp(&name[l-4], ".ttf", 4)) - type=2; - if(type) - { - char*fontname = (char*)malloc(strlen(dirname)+strlen(name)+2); - strcpy(fontname, dirname); -#ifdef WIN32 - strcat(fontname, "\\"); -#else - strcat(fontname, "/"); -#endif - strcat(fontname, name); - if(!numfonts) - msg(" Adding %s to fonts", fontname); - pdfswf_addfont(fontname); - if(numfonts) - (*numfonts)++; - } - } - closedir(dir); -} -#endif - -char* stripfilename(char*filename, char*newext) +static char* stripfilename(char*filename, char*newext) { char*last1 = strrchr(filename, '/'); char*last2 = strrchr(filename, '\\'); @@ -418,6 +369,8 @@ int main(int argn, char *argv[]) int numfonts = 0; int t; char t1searchpath[1024]; + + initLog(0,-1,0,0,-1,loglevel); #if defined(WIN32) && defined(HAVE_STAT) && defined(HAVE_SYS_STAT_H) FILE*test = fopen(FONTDIR "\\d050000l.afm", "rb"); @@ -437,7 +390,6 @@ int main(int argn, char *argv[]) #endif #endif processargs(argn, argv); - initLog(0,-1,0,0,-1,loglevel); if(!filename) { @@ -467,33 +419,36 @@ int main(int argn, char *argv[]) exit(0); } -#ifdef HAVE_DIRENT_H - // pass 1 - addfontdir(FONTDIR, &numfonts); - for(t=0;t Couldn't find any fonts!"); -#endif - - pdfswf_init(filename, password); - pdfswf_setoutputfilename(outputname); - int pages = pdfswf_numpages(); - for(t = 1; t <= pages; t++) - { - if(is_in_range(t, pagerange)) - pdfswf_convertpage(t); + pdf_doc_t* pdf = pdf_init(filename, password); + if(!pdf) { + msg(" Couldn't open %s", filename); + exit(1); } - pdfswf_performconversion(); + swf_output_t* swf = swf_output_init(); - pdfswf_close(); + for(t = 1; t <= pdf->num_pages; 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); + } + } + if(!swf_output_save(swf, outputname)) + exit(1); + swf_output_destroy(swf); + + pdf_destroy(pdf); if(viewer || preloader) { #ifndef SYSTEM_BACKTICKS @@ -528,4 +483,3 @@ int main(int argn, char *argv[]) return 0; } -