create GFXGlobalParams instead of GlobalParams
[swftools.git] / lib / pdf / pdf.cc
index c97825d..25a1770 100644 (file)
@@ -179,7 +179,7 @@ static char*getInfoString(Dict *infoDict, char *key)
     GString *s1, *s2;
     int i;
 
-    if (infoDict->lookup(key, &obj)->isString()) {
+    if (infoDict && infoDict->lookup(key, &obj)->isString()) {
        s1 = obj.getString();
        if ((s1->getChar(0) & 0xff) == 0xfe &&
            (s1->getChar(1) & 0xff) == 0xff) {
@@ -211,7 +211,7 @@ static char*getInfoDate(Dict *infoDict, char *key)
     Object obj;
     char *s;
 
-    if (infoDict->lookup(key, &obj)->isString()) {
+    if (infoDict && infoDict->lookup(key, &obj)->isString()) {
        s = obj.getString()->getCString();
        if (s[0] == 'D' && s[1] == ':') {
          s += 2;
@@ -318,10 +318,6 @@ static gfxdocument_t*pdf_open(const char*filename)
     GString *fileName = new GString(filename);
     GString *userPW;
 
-    // read config file
-    if(!globalParams)
-        globalParams = new GlobalParams("");
-
     // open PDF file
     if (userPassword && userPassword[0]) {
       userPW = new GString(userPassword);
@@ -351,7 +347,7 @@ static gfxdocument_t*pdf_open(const char*filename)
               i->protect = 1;
     }
 
-    InfoOutputDev*io = new InfoOutputDev();
+    InfoOutputDev*io = new InfoOutputDev(i->doc->getXRef());
     int t;
     i->pages = (pdf_page_info_t*)malloc(sizeof(pdf_page_info_t)*pdf_doc->num_pages);
     memset(i->pages,0,sizeof(pdf_page_info_t)*pdf_doc->num_pages);
@@ -387,6 +383,10 @@ static gfxdocument_t*pdf_open(const char*filename)
 
 gfxsource_t*gfxsource_pdf_create()
 {
+    if(!globalParams) {
+        globalParams = new GFXGlobalParams();
+    }
+    
     gfxsource_t*src = (gfxsource_t*)malloc(sizeof(gfxsource_t));
     memset(src, 0, sizeof(gfxsource_t));
     src->set_parameter = pdf_set_parameter;