X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpdf%2Fpdf.cc;h=368416e1a9ab11764e248b182b8d317909b2eaff;hb=64b820f5aa8bb7f2df9f297e325434f043e2d25b;hp=7d13c7b1db509bd59a7dc9899783b177339a21b0;hpb=dd130e1db77e857ace5d225d3fca175526c55681;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index 7d13c7b..368416e 100644 --- a/lib/pdf/pdf.cc +++ b/lib/pdf/pdf.cc @@ -6,6 +6,7 @@ #include "GlobalParams.h" #include "InfoOutputDev.h" #include "GFXOutputDev.h" +#include "FullBitmapOutputDev.h" #include "BitmapOutputDev.h" #include "../mem.h" #include "pdf.h" @@ -18,8 +19,7 @@ static int ppm_dpi = 0; static int multiply = 1; static char* global_page_range = 0; -static parameter_t* device_config = 0; -static parameter_t* device_config_next = 0; +static int globalparams_count=0; typedef struct _pdf_page_info { @@ -34,12 +34,15 @@ typedef struct _pdf_page_info typedef struct _pdf_doc_internal { int protect; + int nocopy; PDFDoc*doc; Object docinfo; InfoOutputDev*info; CommonOutputDev*outputDev; pdf_page_info_t*pages; gfxdevice_t* middev; + char*filename; + gfxsource_t*parent; } pdf_doc_internal_t; typedef struct _pdf_page_internal @@ -51,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() { @@ -96,13 +116,15 @@ void render2(gfxpage_t*page, gfxdevice_t*dev) } /* pass global parameters to output device */ - parameter_t*p = device_config; + 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(); + pi->outputDev->setDevice(0); if(pi->middev) { gfxdevice_rescale_setdevice(pi->middev, 0x00000000); @@ -130,8 +152,6 @@ void pdfpage_rendersection(gfxpage_t*page, gfxdevice_t*output, gfxcoord_t x, gfx render2(page, output); } -static int globalparams_count=0; - void pdf_doc_destroy(gfxdocument_t*gfx) { pdf_doc_internal_t*i= (pdf_doc_internal_t*)gfx->internal; @@ -147,6 +167,10 @@ void pdf_doc_destroy(gfxdocument_t*gfx) free(i->pages); i->pages = 0; i->docinfo.free(); + + if(i->filename) { + free(i->filename);i->filename=0; + } if(i->info) { delete i->info;i->info=0; @@ -281,26 +305,32 @@ char* pdf_doc_getinfo(gfxdocument_t*doc, const char*name) } -static void storeDeviceParameter(const char*name, const char*value) +static void storeDeviceParameter(gfxsource_internal_t*i, const char*name, const char*value) { + 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(device_config_next) { - device_config_next->next = p; - device_config_next = p; + + if(i->device_config_next) { + i->device_config_next->next = p; + i->device_config_next = p; } else { - device_config = p; - device_config_next = p; + i->device_config = p; + i->device_config_next = p; } } -typedef struct _gfxsource_internal -{ - int config_bitmap_optimizing; -} gfxsource_internal_t; - static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value) { gfxsource_internal_t*i = (gfxsource_internal_t*)src->internal; @@ -309,7 +339,7 @@ static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value addGlobalFontDir(value); } else if(!strcmp(name, "pages")) { global_page_range = strdup(value); - } else if(!strncmp(name, "font", strlen("font"))) { + } else if(!strncmp(name, "font", strlen("font")) && name[4]!='q') { addGlobalFont(value); } else if(!strncmp(name, "languagedir", strlen("languagedir"))) { addGlobalLanguageDir(value); @@ -317,31 +347,36 @@ 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")) { + i->config_full_bitmap_optimizing = atoi(value); } else if(!strcmp(name, "multiply")) { multiply = atoi(value); } else if(!strcmp(name, "help")) { printf("\nPDF device global parameters:\n"); - printf("fontdir=