X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;h=aaf1945315135fbc4a142a8c8274afa6c790726d;hb=f5fbd173ec19772ac0689d8644b90b36ec0a7daa;hp=883475ea7f18e8e6d92a57301c562decbe98d705;hpb=4461ee0f7fad532c3443a67ca46da207f579adb5;p=swftools.git diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index 883475e..aaf1945 100644 --- a/pdf2swf/pdf2swf.cc +++ b/pdf2swf/pdf2swf.cc @@ -32,22 +32,19 @@ #include #endif #include "../lib/args.h" +#include "../lib/os.h" #include "SWFOutputDev.h" #include "log.h" -#ifndef WIN32 -#define FONTDIR SWFTOOLS_DATADIR "/fonts" -#define SWFDIR SWFTOOLS_DATADIR "/swfs" -#else -#define FONTDIR "C:\\swftools\\fonts" -#define SWFDIR "C:\\swftools\\swfs" -#endif +#define FONTDIR concatPaths(getInstallationPath(), "fonts") +#define SWFDIR concatPaths(getInstallationPath(), "swfs") static char * outputname = 0; static int loglevel = 3; static char * pagerange = 0; static char * filename = 0; static char * password = 0; +static int zlib = 0; static char * preloader = 0; static char * viewer = 0; @@ -154,6 +151,7 @@ int args_callback_option(char*name,char*val) { else if (!strcmp(name, "z")) { pdfswf_setparameter("enablezlib", "1"); + zlib = 1; return 0; } else if (!strcmp(name, "n")) @@ -344,37 +342,19 @@ void args_callback_usage(char*name) " graphic errors)\n"); printf("-s filloverlap Make intersecting shapes overlap, instead of canceling each\n" " other out. (Needed for some Powerpoint PDFs)\n"); - printf("-2 Put 2 pages into each frame.\n"); - printf("-4 Put 4 pages into each frame.\n"); + //deliberately undocumented (for now) + //printf("-2 Put 2 pages into each frame.\n"); + //printf("-4 Put 4 pages into each frame.\n"); printf("Postprocessing options:\n"); #ifndef SYSTEM_BACKTICKS printf("(They might not work because your system call doesn't support command substitution)\n"); #endif - printf("-b --defaultviewer Link default viewer to the pdf (%s/swfs/default_viewer.swf)\n", SWFTOOLS_DATADIR); - printf("-l --defaultpreloader Link default preloader the pdf (%s/swfs/default_loader.swf)\n", SWFTOOLS_DATADIR); + printf("-b --defaultviewer Link default viewer to the pdf (%s)\n", concatPaths(SWFDIR, "default_viewer.swf")); + printf("-l --defaultpreloader Link default preloader the pdf (%s)\n", concatPaths(SWFDIR, "default_loader.swf")); printf("-B --viewer=filename Link viewer \"name\" to the pdf (\"%s -B\" for list)\n", name); printf("-L --preloader=filename Link preloader \"name\" to the pdf (\"%s -L\" for list)\n",name); } -static char* stripfilename(char*filename, char*newext) -{ - char*last1 = strrchr(filename, '/'); - char*last2 = strrchr(filename, '\\'); - char*pos = filename; - char*name; - char*dot; - if(last1>pos) pos = last1 + 1; - if(last2>pos) pos = last2 + 1; - name = (char*)malloc(strlen(pos)+5); - strcpy(name, pos); - dot = strrchr(name, '.'); - if(dot) { - *dot = 0; - } - strcat(name, newext); - return name; -} - int main(int argn, char *argv[]) { int ret; @@ -388,9 +368,9 @@ int main(int argn, char *argv[]) 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"); + FILE*test = fopen(concatPaths(FONTDIR,"\\d050000l.afm"), "rb"); if(!test) { - fprintf(stderr, "Couldn't find file " FONTDIR "\\d050000l.afm- pdf2swf not installed properly? OS says:\n"); + fprintf(stderr, "Couldn't find file %s - pdf2swf not installed properly? OS says:\n", concatPaths(FONTDIR, "\\d050000l.afm")); perror("open"); exit(1); } @@ -415,7 +395,7 @@ int main(int argn, char *argv[]) if(!outputname) { if(filename) { - outputname = stripfilename(filename, ".swf"); + outputname = stripFilename(filename, ".swf"); msg(" Output filename not given. Writing to %s", outputname); } } @@ -496,15 +476,19 @@ int main(int argn, char *argv[]) printf("\n"); } + char*zip = ""; + if(zlib) + zip = "-z"; + if(viewer && !preloader) { - systemf("swfcombine `swfdump -XY \"%s\"` \"%s\" viewport=\"%s\" -o \"%s\"", + systemf("swfcombine %s `swfdump -XY \"%s\"` \"%s\" viewport=\"%s\" -o \"%s\"",zip, 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 %s `swfdump -r \"%s\"` %s/PreLoaderTemplate.swf loader=\"%s\" movie=\"%s\" -o \"%s\"",zip, preloader, SWFDIR, preloader, outputname, outputname); if(!system_quiet) printf("\n"); @@ -512,7 +496,7 @@ int main(int argn, char *argv[]) if(preloader && viewer) { 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 %s `swfdump -XY \"%s\"` `swfdump -r \"%s\"` %s/PreLoaderTemplate.swf loader=%s movie=__tmp__.swf -o \"%s\"",zip, outputname, preloader, SWFDIR, preloader, outputname); systemf("rm __tmp__.swf"); }