X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2Fpdf.cc;h=965919a94fe1834904ebfcc01bc7e56e0f2cf475;hb=9a675c2ff1b3a8eae9b7f25f3f96441016c5b70f;hp=7d13c7b1db509bd59a7dc9899783b177339a21b0;hpb=dd130e1db77e857ace5d225d3fca175526c55681;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index 7d13c7b..965919a 100644 --- a/lib/pdf/pdf.cc +++ b/lib/pdf/pdf.cc @@ -34,6 +34,7 @@ typedef struct _pdf_page_info typedef struct _pdf_doc_internal { int protect; + int nocopy; PDFDoc*doc; Object docinfo; InfoOutputDev*info; @@ -187,6 +188,10 @@ gfxpage_t* pdf_doc_getpage(gfxdocument_t*doc, int page) if(page < 1 || page > doc->num_pages) return 0; + if(di->nocopy) { + msg(" PDF disallows copying."); + return 0; + } gfxpage_t* pdf_page = (gfxpage_t*)malloc(sizeof(gfxpage_t)); pdf_page_internal_t*pi= (pdf_page_internal_t*)malloc(sizeof(pdf_page_internal_t)); @@ -283,10 +288,21 @@ char* pdf_doc_getinfo(gfxdocument_t*doc, const char*name) static void storeDeviceParameter(const char*name, const char*value) { + parameter_t*o = device_config; + while(o) { + if(!strcmp(name, o->name)) { + /* overwrite old value */ + free(o->value); + o->value = strdup(value); + return; + } + o = o->next; + } parameter_t*p = new parameter_t(); p->name = strdup(name); p->value = strdup(value); p->next = 0; + if(device_config_next) { device_config_next->next = p; device_config_next = p; @@ -387,8 +403,7 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) i->protect = 0; if (i->doc->isEncrypted()) { if(!i->doc->okToCopy()) { - printf("PDF disallows copying.\n"); - return 0; + i->nocopy = 1; } if(!i->doc->okToChange() || !i->doc->okToAddNotes()) i->protect = 1; @@ -422,7 +437,6 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) GFXOutputDev*outputDev = new GFXOutputDev(i->info, i->doc); i->outputDev = (CommonOutputDev*)outputDev; } - /* pass global parameters to PDF driver*/ parameter_t*p = device_config; while(p) {