X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=inline;f=lib%2Fpdf%2Fpdf.cc;h=98fb665f7e38d2bcbc67b0d865538987cb987748;hb=902612a0ae5ed5105e133e0fbc765a480cd88823;hp=9390e4a28b214ad8119632f734c8b4749d705047;hpb=d0f9d82a8652cedc913671a2caf8d7a367beadb1;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index 9390e4a..98fb665 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" @@ -21,6 +22,8 @@ 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 { int xMin, yMin, xMax, yMax; @@ -41,6 +44,7 @@ typedef struct _pdf_doc_internal CommonOutputDev*outputDev; pdf_page_info_t*pages; gfxdevice_t* middev; + char*filename; } pdf_doc_internal_t; typedef struct _pdf_page_internal @@ -104,6 +108,8 @@ void render2(gfxpage_t*page, gfxdevice_t*dev) } 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); @@ -131,8 +137,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; @@ -148,6 +152,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; @@ -288,10 +296,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; @@ -304,6 +323,7 @@ static void storeDeviceParameter(const char*name, const char*value) typedef struct _gfxsource_internal { int config_bitmap_optimizing; + int config_full_bitmap_optimizing; } gfxsource_internal_t; static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value) @@ -314,7 +334,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); @@ -337,14 +357,20 @@ static void pdf_set_parameter(gfxsource_t*src, const char*name, const char*value storeDeviceParameter("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=