X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;h=a87c6e29765d7af6d0674bb7da44d029d3b367a7;hb=4f75737b61a4d259a49e5ebc9e21c2cbcfd84c37;hp=fe5cad62025996a8eb9de92724d5d77b0f3b39b7;hpb=1e3b0a04224e5c313021f6fb3737ac8a87e992ac;p=swftools.git diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index fe5cad6..a87c6e2 100644 --- a/pdf2swf/pdf2swf.cc +++ b/pdf2swf/pdf2swf.cc @@ -33,7 +33,6 @@ #endif #include "../lib/args.h" #include "SWFOutputDev.h" -#include "t1lib.h" extern "C" { #include "log.h" } @@ -133,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")) @@ -227,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; } } @@ -318,18 +318,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"); @@ -341,13 +344,8 @@ void args_callback_usage(char*name) } #ifdef HAVE_DIRENT_H -void addfontdir(FILE*database, char* dirname, int*numfonts, char*searchpath) +void addfontdir(char* dirname, int*numfonts) { - if(searchpath) { - if(searchpath[0]) - strcat(searchpath, ":"); - strcat(searchpath, dirname); - } if(!numfonts) msg(" Adding %s to search path\n", dirname); @@ -368,36 +366,25 @@ void addfontdir(FILE*database, char* dirname, int*numfonts, char*searchpath) l=strlen(name); if(l<4) continue; - if(!strncasecmp(&name[l-4], ".afm", 4)) + 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) { - if(database && type==1) { - char buf[256],a; - FILE*fi; + char*fontname = (char*)malloc(strlen(dirname)+strlen(name)+2); + strcpy(fontname, dirname); #ifdef WIN32 - sprintf(buf, "%s\\%s", dirname,name); + strcat(fontname, "\\"); #else - sprintf(buf, "%s/%s", dirname,name); + strcat(fontname, "/"); #endif - fi = fopen(buf, "rb"); - if(!fi || !fread(&a,1,1,fi)) { - msg(" Couldn't read from %s", buf); - } - -#ifdef WIN32 -/* might also work for all other systems, but we *need* it for win32 */ - if(!strncmp(buf, FONTDIR, strlen(FONTDIR))) - fprintf(database, "%s\n", buf+strlen(FONTDIR)); - else -#endif - fprintf(database, "%s\n", buf); - - msg(" Found font %s\n", buf); - fclose(fi); - } + strcat(fontname, name); + if(!numfonts) + msg(" Adding %s to fonts", fontname); + pdfswf_addfont(fontname); if(numfonts) (*numfonts)++; } @@ -481,74 +468,20 @@ int main(int argn, char *argv[]) exit(0); } - msg(" reading font files from %s\n", FONTDIR); - //TODO: use tempnam here. Check if environment already contains a - //T1LIB_CONFIG. - putenv( "T1LIB_CONFIG=/tmp/t1lib.config.tmp"); - FILE*db = fopen("/tmp/FontDataBase", "wb"); - FILE*fi = fopen("/tmp/t1lib.config.tmp", "wb"); - if(!db || !fi) { - fprintf(stderr, "Couldn't create temporary file in /tmp/\n"); - exit(1); - } - t1searchpath[0] = 0; #ifdef HAVE_DIRENT_H // pass 1 - addfontdir(0, FONTDIR, &numfonts, 0); + addfontdir(FONTDIR, &numfonts); for(t=0;t Couldn't find any fonts!"); #endif - fclose(fi); - fclose(db); - /* initialize t1lib */ - T1_SetBitmapPad( 16); - if ((T1_InitLib(LOGFILE)==NULL)){ - fprintf(stderr, "Initialization of t1lib failed\n"); - exit(1); - } - unlink("/tmp/t1lib.config.tmp"); pdfswf_init(filename, password); pdfswf_setoutputfilename(outputname); @@ -573,27 +506,26 @@ int main(int argn, char *argv[]) } if(viewer && !preloader) { - systemf("swfcombine `swfdump -XY %s` %s viewport=%s -o %s", + systemf("swfcombine `swfdump -XY \"%s\"` \"%s\" viewport=\"%s\" -o \"%s\"", outputname, viewer, outputname, outputname); if(!system_quiet) printf("\n"); } if(preloader && !viewer) { msg(" --preloader option without --viewer option doesn't make very much sense."); - ret = systemf("swfcombine `swfdump -r %s` %s/PreLoaderTemplate.swf loader=%s movie=%s -o %s", + ret = systemf("swfcombine `swfdump -r \"%s\"` %s/PreLoaderTemplate.swf loader=\"%s\" movie=\"%s\" -o \"%s\"", preloader, SWFDIR, preloader, outputname, outputname); if(!system_quiet) printf("\n"); } if(preloader && viewer) { - systemf("swfcombine %s viewport=%s -o __tmp__.swf", + systemf("swfcombine \"%s\" viewport=%s -o __tmp__.swf", viewer, outputname, outputname); - systemf("swfcombine `swfdump -XY %s` `swfdump -r %s` %s/PreLoaderTemplate.swf loader=%s movie=__tmp__.swf -o %s", + systemf("swfcombine `swfdump -XY \"%s\"` `swfdump -r \"%s\"` %s/PreLoaderTemplate.swf loader=%s movie=__tmp__.swf -o \"%s\"", outputname, preloader, SWFDIR, preloader, outputname); systemf("rm __tmp__.swf"); } - unlink("/tmp/FontDataBase"); return 0; }