pi->outputDev->setDevice(0);
}
+static int globalparams_count=0;
+
void pdf_doc_destroy(gfxdocument_t*gfx)
{
pdf_doc_internal_t*i= (pdf_doc_internal_t*)gfx->internal;
free(global_page_range);
global_page_range = 0;
}
+
+ globalparams_count--;
+ if(!globalparams_count) {
+ delete globalParams;
+ globalParams = 0;
+ globalparams_count = 0;
+ }
}
void pdf_doc_set_parameter(gfxdocument_t*gfx, const char*name, const char*value)
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) {
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;
static gfxdocument_t*pdf_open(const char*filename)
{
+ if(!globalParams) {
+ globalParams = new GFXGlobalParams();
+ globalparams_count++;
+ }
+
gfxdocument_t*pdf_doc = (gfxdocument_t*)malloc(sizeof(gfxdocument_t));
memset(pdf_doc, 0, sizeof(gfxdocument_t));
pdf_doc_internal_t*i= (pdf_doc_internal_t*)malloc(sizeof(pdf_doc_internal_t));
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);