fixed clipping bug: More than one clipping region inside a saved state
[swftools.git] / pdf2swf / pdf2swf.cc
index c784f80..20f9348 100644 (file)
@@ -12,7 +12,7 @@
 #include <string.h>
 #include <unistd.h>
 #include "../config.h"
-#include "args.h"
+#include "../lib/args.h"
 #include "pdfswf.h"
 #include "t1lib.h"
 extern "C" {
@@ -66,6 +66,16 @@ int args_callback_option(char*name,char*val) {
        pdfswf_ignoredraworder();
        return 0;
     }
+    else if (!strcmp(name, "n"))
+    {
+       pdfswf_linksopennewwindow();
+       return 0;
+    }
+    else if (!strcmp(name, "f"))
+    {
+       pdfswf_storeallcharacters();
+       return 0;
+    }
     else if (name[0]=='j')
     {
        if(name[1]) {
@@ -89,39 +99,20 @@ int args_callback_option(char*name,char*val) {
     return 0;
 }
 
-struct options_t
-{
-    char shortoption;
-    char*longoption;
-} options[] =
-{{'o',"output"},
- {'V',"version"},
- {'i',"ignore"},
- {'s',"shapes"},
- {'j',"jpegquality"},
- {'p',"pages"}
+struct options_t options[] =
+{{"o","output"},
+ {"V","version"},
+ {"i","ignore"},
+ {"s","shapes"},
+ {"j","jpegquality"},
+ {"p","pages"},
+ {"w","samewindow"},
+ {"f","fonts"},
+ {0,0}
 };
 
 int args_callback_longoption(char*name,char*val) {
-    int t;
-    char*equal = strchr(name,'=');
-    if (equal) {
-       *equal = 0;
-       equal++;
-    }
-    for(t=0;t<sizeof(options)/sizeof(struct options_t);t++) {
-        if(!strcmp(options[t].longoption, name)) {
-               char*tmp = (char*)malloc(strlen(name)+(equal?strlen(equal)+2:2));
-               tmp[0] = options[t].shortoption;
-               tmp[1] = 0;
-               if(equal) {
-                   strcpy(&tmp[1], equal);
-               }
-               return args_callback_option(tmp,val);
-       }
-    }
-    fprintf(stderr, "Unknown option: --%s\n", name);
-    exit(1);
+    return args_long2shortoption(options, name, val);
 }
 
 int args_callback_command(char*name, char*val) {
@@ -149,6 +140,8 @@ void args_callback_usage(char*name)
     printf("-i  --ignore               Ignore draw order (makes the SWF file smaller)\n");
     printf("-j  --jpegquality=quality  Set quality of embedded jpeg pictures (default:85)\n");
     printf("-v  --verbose              Be verbose. Use more than one -v for greater effect\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("-V  --version              Print program version\n");
 }
 
@@ -232,6 +225,11 @@ int main(int argn, char *argv[])
     srand48(time(0));
     processargs(argn, argv);
     initLog(0,-1,0,0,-1,loglevel);
+    if(!outputname)
+    {
+       fprintf(stderr, "Please use -o to specify an output file\n");
+       exit(1);
+    }
 
     // test if the page range is o.k.
     is_in_range(0x7fffffff, pagerange);
@@ -269,6 +267,7 @@ int main(int argn, char *argv[])
        if(is_in_range(t, pagerange))
        pdfswf_convertpage(t);
     }
+    pdfswf_performconversion();
 
     pdfswf_close();
     return 0;