X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2Fpdf.cc;h=1d56679026bc19256d74e6d5db1334b1e207c342;hb=bac8d2e4da298000c30c6f63031542b3b8cee7c5;hp=965919a94fe1834904ebfcc01bc7e56e0f2cf475;hpb=9a675c2ff1b3a8eae9b7f25f3f96441016c5b70f;p=swftools.git diff --git a/lib/pdf/pdf.cc b/lib/pdf/pdf.cc index 965919a..1d56679 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 @@ -131,8 +135,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 +150,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; @@ -315,6 +321,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) @@ -348,12 +355,14 @@ 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= a directory with additional fonts\n"); - printf("font= an dditional font filename\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"); } @@ -370,7 +379,7 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) pdf_doc->internal = i; char*userPassword=0; - filename = strdup(filename); + i->filename = strdup(filename); char*x = 0; if((x = strchr(filename, '|'))) { @@ -430,13 +439,17 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) } } - if(isrc->config_bitmap_optimizing) { + if(isrc->config_full_bitmap_optimizing) { + FullBitmapOutputDev*outputDev = new FullBitmapOutputDev(i->info, i->doc); + i->outputDev = (CommonOutputDev*)outputDev; + } else if(isrc->config_bitmap_optimizing) { BitmapOutputDev*outputDev = new BitmapOutputDev(i->info, i->doc); i->outputDev = (CommonOutputDev*)outputDev; } else { 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) { @@ -460,6 +473,23 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename) return pdf_doc; } + +void pdf_destroy(gfxsource_t*src) +{ + if(!src->internal) + return; + gfxsource_internal_t*i = (gfxsource_internal_t*)src->internal; + free(src->internal);src->internal=0; + + parameter_t*p = device_config; + while(p) { + parameter_t*next = p->next; + p->next = 0;delete p; + p = next; + } + delete globalParams;globalParams = 0; + free(src); +} gfxsource_t*gfxsource_pdf_create() { @@ -467,6 +497,7 @@ gfxsource_t*gfxsource_pdf_create() memset(src, 0, sizeof(gfxsource_t)); src->set_parameter = pdf_set_parameter; src->open = pdf_open; + src->destroy = pdf_destroy; src->internal = malloc(sizeof(gfxsource_internal_t)); memset(src->internal, 0, sizeof(gfxsource_internal_t));