X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2Fpdf.cc;h=885ebbf5814db97adea72404a72212915e98d755;hb=9f78f7ab7c789bbd7c95e0d6e505bdce17f663c2;hp=f7fb640e729bd589d87f6df081f4f80879205f1f;hpb=21a3f7b017e8bc721f55c9f3365005b57b19816a;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index f7fb640..885ebbf 100644 --- a/lib/pdf/pdf.cc +++ b/lib/pdf/pdf.cc @@ -8,7 +8,6 @@ #include "GFXOutputDev.h" #include "FullBitmapOutputDev.h" #include "BitmapOutputDev.h" -#include "DummyOutputDev.h" #include "../mem.h" #include "pdf.h" #define NO_ARGPARSER @@ -20,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 { @@ -99,14 +97,10 @@ void render2(gfxpage_t*page, gfxdevice_t*dev) dev->setparameter(dev, "protect", "1"); } - /* pass global parameters to output device */ - parameter_t*p = 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); @@ -134,8 +128,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; @@ -195,10 +187,6 @@ 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)); @@ -292,33 +280,6 @@ char* pdf_doc_getinfo(gfxdocument_t*doc, const char*name) return 0; } - -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; - } else { - device_config = p; - device_config_next = p; - } -} - typedef struct _gfxsource_internal { int config_bitmap_optimizing; @@ -333,7 +294,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); @@ -361,13 +322,20 @@ 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("\nPDF device global parameters:\n"); - printf("fontdir= a directory with additional fonts\n"); - printf("font= an dditional font filename\n"); - printf("pages= the range of pages to convert (example: pages=1-100,210-)\n"); - printf("zoom= the resultion (default: 72)\n"); + printf("fontdir= a directory with additional fonts\n"); + printf("font= an additional font filename\n"); + printf("pages= the range of pages to convert (example: pages=1-100,210-)\n"); + printf("zoom= the resultion (default: 72)\n"); + printf("bitmap Convert everything to bitmaps\n"); + printf("poly2bitmap Convert graphics to bitmaps\n"); + printf("languagedir= Add an xpdf language directory\n"); + printf("multiply= Render everything at the resolution\n"); + printf("breakonwarning=0/1 Abort conversion if graphic objects are found which\n"); + printf(" are not 100%% supported\n"); + printf("transparent=0/1 Make output file transparent (alpha background)\n"); + printf("extrafontdata=0/1 Store Type3 characters and capture characters\n"); + printf("fontquality=1..100 Curve approximation quality of the fonts\n"); } - storeDeviceParameter(name,value); } static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) @@ -451,13 +419,6 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) i->outputDev = (CommonOutputDev*)outputDev; } - /* pass global parameters to PDF driver*/ - parameter_t*p = device_config; - while(p) { - i->outputDev->setParameter(p->name, p->value); - p = p->next; - } - i->middev = 0; if(multiply>1) { i->middev = (gfxdevice_t*)malloc(sizeof(gfxdevice_t)); @@ -481,6 +442,9 @@ void pdf_destroy(gfxsource_t*src) return; gfxsource_internal_t*i = (gfxsource_internal_t*)src->internal; free(src->internal);src->internal=0; + + delete globalParams;globalParams = 0; + free(src); } gfxsource_t*gfxsource_pdf_create()