X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2Fpdf.cc;h=965919a94fe1834904ebfcc01bc7e56e0f2cf475;hb=9a675c2ff1b3a8eae9b7f25f3f96441016c5b70f;hp=ea7b3f6576fc8ddd89999d54c2774be1b855425e;hpb=b2b8805d2034f3beb7d26dbf0b49c2b110580ef0;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index ea7b3f6..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; @@ -78,7 +79,6 @@ void render2(gfxpage_t*page, gfxdevice_t*dev) pi->middev->setparameter(pi->middev, "protect", "1"); dev = pi->middev; } - dev->setparameter(dev, "protect", "1"); if(!pi) { msg(" pdf_page_render: Parent PDF this page belongs to doesn't exist yet/anymore"); @@ -188,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)); @@ -284,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; @@ -332,7 +347,7 @@ static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value sprintf(buf, "%f", (double)ppm_dpi/(double)zoom); storeDeviceParameter("ppmsubpixels", buf); } else if(!strcmp(name, "poly2bitmap")) { - i->config_bitmap_optimizing = 1; + i->config_bitmap_optimizing = atoi(value); } else if(!strcmp(name, "multiply")) { multiply = atoi(value); } else if(!strcmp(name, "help")) { @@ -388,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; @@ -423,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) {