X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpdf%2Fpdf.cc;h=368416e1a9ab11764e248b182b8d317909b2eaff;hb=dc811a3e72d1926e8a0607b1f0571596c2f4e1a6;hp=885ebbf5814db97adea72404a72212915e98d755;hpb=9f78f7ab7c789bbd7c95e0d6e505bdce17f663c2;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index 885ebbf..368416e 100644 --- a/lib/pdf/pdf.cc +++ b/lib/pdf/pdf.cc @@ -42,6 +42,7 @@ typedef struct _pdf_doc_internal pdf_page_info_t*pages; gfxdevice_t* middev; char*filename; + gfxsource_t*parent; } pdf_doc_internal_t; typedef struct _pdf_page_internal @@ -53,6 +54,23 @@ typedef struct _dev_output_internal CommonOutputDev*outputDev; } dev_output_internal_t; +typedef struct _parameter +{ + struct _parameter *next; + const char*name; + const char*value; +} parameter_t; + +typedef struct _gfxsource_internal +{ + int config_bitmap_optimizing; + int config_full_bitmap_optimizing; + + parameter_t* device_config; + parameter_t* device_config_next; + +} gfxsource_internal_t; + static char* dirseparator() { @@ -97,6 +115,12 @@ void render2(gfxpage_t*page, gfxdevice_t*dev) dev->setparameter(dev, "protect", "1"); } + /* pass global parameters to output device */ + parameter_t*p = ((gfxsource_internal_t*)pi->parent->internal)->device_config; + while(p) { + dev->setparameter(dev, p->name, p->value); + p = p->next; + } pi->doc->displayPage((OutputDev*)pi->outputDev, page->nr, zoom*multiply, zoom*multiply, /*rotate*/0, true, true, /*doLinks*/(int)1); pi->doc->processLinks((OutputDev*)pi->outputDev, page->nr); pi->outputDev->finishPage(); @@ -280,11 +304,32 @@ char* pdf_doc_getinfo(gfxdocument_t*doc, const char*name) return 0; } -typedef struct _gfxsource_internal + +static void storeDeviceParameter(gfxsource_internal_t*i, const char*name, const char*value) { - int config_bitmap_optimizing; - int config_full_bitmap_optimizing; -} gfxsource_internal_t; + parameter_t*o = i->device_config; + while(o) { + if(!strcmp(name, o->name)) { + /* overwrite old value */ + free((void*)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(i->device_config_next) { + i->device_config_next->next = p; + i->device_config_next = p; + } else { + i->device_config = p; + i->device_config_next = p; + } +} static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value) { @@ -302,19 +347,19 @@ static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value char buf[80]; zoom = atof(value); sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom); - storeDeviceParameter("jpegsubpixels", buf); + storeDeviceParameter(i, "jpegsubpixels", buf); sprintf(buf, "%f", (double)ppm_dpi/(double)zoom); - storeDeviceParameter("ppmsubpixels", buf); + storeDeviceParameter(i, "ppmsubpixels", buf); } else if(!strcmp(name, "jpegdpi")) { char buf[80]; jpeg_dpi = atoi(value); sprintf(buf, "%f", (double)jpeg_dpi/(double)zoom); - storeDeviceParameter("jpegsubpixels", buf); + storeDeviceParameter(i, "jpegsubpixels", buf); } else if(!strcmp(name, "ppmdpi")) { char buf[80]; ppm_dpi = atoi(value); sprintf(buf, "%f", (double)ppm_dpi/(double)zoom); - storeDeviceParameter("ppmsubpixels", buf); + storeDeviceParameter(i, "ppmsubpixels", buf); } else if(!strcmp(name, "poly2bitmap")) { i->config_bitmap_optimizing = atoi(value); } else if(!strcmp(name, "bitmapfonts") || !strcmp(name, "bitmap")) { @@ -322,19 +367,15 @@ static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value } else if(!strcmp(name, "multiply")) { multiply = atoi(value); } else if(!strcmp(name, "help")) { - printf("fontdir=