X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;h=a5e7cf81f911a5761562aa294ebbca5e243528e0;hb=335b6b2b798d308f333c371caae0bfc7628506db;hp=fe5cad62025996a8eb9de92724d5d77b0f3b39b7;hpb=1e3b0a04224e5c313021f6fb3737ac8a87e992ac;p=swftools.git diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index fe5cad6..a5e7cf8 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" } @@ -318,18 +317,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 +343,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 +365,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); -#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 + strcat(fontname, "/"); #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 +467,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 -/* This is a workaround. The correct way would be to - get directory listings working on all systems. -*/ - strcpy(t1searchpath, SWFTOOLS_DATADIR); - strcat(t1searchpath, "/fonts"); - fprintf(db, "14\n"); - fprintf(db, "n021003l.afm\n"); - fprintf(db, "n021023l.afm\n"); - fprintf(db, "n021004l.afm\n"); - fprintf(db, "n021024l.afm\n"); - fprintf(db, "n019003l.afm\n"); - fprintf(db, "n019023l.afm\n"); - fprintf(db, "n019004l.afm\n"); - fprintf(db, "n019024l.afm\n"); - fprintf(db, "n022003l.afm\n"); - fprintf(db, "n022023l.afm\n"); - fprintf(db, "n022004l.afm\n"); - fprintf(db, "n022024l.afm\n"); - fprintf(db, "s050000l.afm\n"); - fprintf(db, "d050000l.afm\n"); -#endif - - fprintf(fi, "FONTDATABASE=/tmp/FontDataBase\n"); -#ifndef WIN32 - fprintf(fi, "ENCODING=%s:.\n", t1searchpath); - fprintf(fi, "AFM=%s:.\n", t1searchpath); - fprintf(fi, "TYPE1=%s:.\n", t1searchpath); -#else - fprintf(fi, "ENCODING=%s\n", FONTDIR); - fprintf(fi, "AFM=%s\n", FONTDIR); - fprintf(fi, "TYPE1=%s\n", FONTDIR); -#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 +505,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; }