From 820f9a355fae63700e7b29e992942e8e5dc8c211 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Sat, 15 Aug 2009 23:07:31 +0200 Subject: [PATCH] multi-page fix --- lib/devices/pdf.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/devices/pdf.c b/lib/devices/pdf.c index 720abd1..05eaac0 100644 --- a/lib/devices/pdf.c +++ b/lib/devices/pdf.c @@ -43,11 +43,14 @@ int pdf_setparameter(gfxdevice_t*dev, const char*key, const char*value) void pdf_startpage(gfxdevice_t*dev, int width, int height) { internal_t*i = (internal_t*)dev->internal; - - i->tempfile = strdup("tmp.pdf"); - PDF_open_file(i->p, i->tempfile); - PDF_set_parameter(i->p, "usercoordinates", "true"); - PDF_set_parameter(i->p, "topdown", "true"); + + if(!i->tempfile) { + i->tempfile = strdup("tmp.pdf"); + PDF_open_file(i->p, i->tempfile); + PDF_set_parameter(i->p, "usercoordinates", "true"); + PDF_set_parameter(i->p, "topdown", "true"); + } + PDF_begin_page(i->p, width, height); PDF_set_parameter(i->p, "fillrule", "evenodd"); } @@ -169,8 +172,6 @@ void pdf_endpage(gfxdevice_t*dev) { internal_t*i = (internal_t*)dev->internal; PDF_end_page(i->p); - PDF_close(i->p); - PDF_delete(i->p); } typedef struct pdfresult_internal { @@ -212,6 +213,9 @@ void* pdfresult_get(gfxresult_t*gfx, const char*name) gfxresult_t* pdf_finish(gfxdevice_t*dev) { internal_t*i = (internal_t*)dev->internal; + + PDF_close(i->p); + PDF_delete(i->p); gfxresult_t*result = (gfxresult_t*)malloc(sizeof(gfxresult_t)); memset(result, 0, sizeof(gfxresult_t)); -- 1.7.10.4