summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2010-02-21 17:24:54 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2010-02-21 17:24:54 +0100
commit8a720825f6ee77d6945833c59609f6a9141dad19 (patch)
treef9a8b461aca7349c6d35817b3dc19eaa068c8ed9
parent18a4e6d9746614227b404df4399471d2a2858f1f (diff)
Use spectre_gs_process() instead of spectre_gs_send_page() in pdf exporter
When rendering with the display device we use a new gs instance for every page and we have to process prolog, setup and trailer for every page. PDF exporter is different, we use a single gs instance created in exporter_pdf_begin() and destroyed in exporter_pdf_end(). Now we use spectre_gs_process() to send prolog and setup in begin() and trailer in end() so that we just send the page contents in do_page(). Fixes bug #26592.
-rw-r--r--libspectre/spectre-exporter-pdf.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/libspectre/spectre-exporter-pdf.c b/libspectre/spectre-exporter-pdf.c
index f4df1d5..3b6beee 100644
--- a/libspectre/spectre-exporter-pdf.c
+++ b/libspectre/spectre-exporter-pdf.c
@@ -30,7 +30,8 @@ spectre_exporter_pdf_begin (SpectreExporter *exporter,
char *args[9];
int arg = 0;
char *output_file;
-
+ struct document *doc = exporter->doc;
+
exporter->gs = spectre_gs_new ();
if (!spectre_gs_create_instance (exporter->gs, NULL)) {
spectre_gs_cleanup (exporter->gs, CLEANUP_DELETE_INSTANCE);
@@ -61,6 +62,28 @@ spectre_exporter_pdf_begin (SpectreExporter *exporter,
free (output_file);
+ if (!spectre_gs_process (exporter->gs,
+ doc->filename,
+ 0, 0,
+ doc->beginprolog,
+ doc->endprolog)) {
+ spectre_gs_free (exporter->gs);
+ exporter->gs = NULL;
+
+ return SPECTRE_STATUS_EXPORTER_ERROR;
+ }
+
+ if (!spectre_gs_process (exporter->gs,
+ doc->filename,
+ 0, 0,
+ doc->beginsetup,
+ doc->endsetup)) {
+ spectre_gs_free (exporter->gs);
+ exporter->gs = NULL;
+
+ return SPECTRE_STATUS_EXPORTER_ERROR;
+ }
+
return SPECTRE_STATUS_SUCCESS;
}
@@ -68,7 +91,13 @@ static SpectreStatus
spectre_exporter_pdf_do_page (SpectreExporter *exporter,
unsigned int page_index)
{
- if (!spectre_gs_send_page (exporter->gs, exporter->doc, page_index, 0, 0)) {
+ struct document *doc = exporter->doc;
+
+ if (!spectre_gs_process (exporter->gs,
+ doc->filename,
+ 0, 0,
+ doc->pages[page_index].begin,
+ doc->pages[page_index].end)) {
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
@@ -81,10 +110,18 @@ spectre_exporter_pdf_do_page (SpectreExporter *exporter,
static SpectreStatus
spectre_exporter_pdf_end (SpectreExporter *exporter)
{
+ int ret;
+ struct document *doc = exporter->doc;
+
+ ret = spectre_gs_process (exporter->gs,
+ doc->filename,
+ 0, 0,
+ doc->begintrailer,
+ doc->endtrailer);
spectre_gs_free (exporter->gs);
exporter->gs = NULL;
- return SPECTRE_STATUS_SUCCESS;
+ return ret ? SPECTRE_STATUS_SUCCESS : SPECTRE_STATUS_EXPORTER_ERROR;
}
SpectreExporter *