summaryrefslogtreecommitdiff
path: root/pdf/ghostpdf.h
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2023-04-20 15:52:59 +0100
committerKen Sharp <ken.sharp@artifex.com>2023-04-20 15:52:59 +0100
commit1b160b94329d28f5c0b7bc682abd6335175bd50e (patch)
treedbbb280648748af446da38eb73b0879669a734bd /pdf/ghostpdf.h
parent7c8ea1623b22247145a438ab2bf081b697e5dc19 (diff)
downloadghostpdl-1b160b94329d28f5c0b7bc682abd6335175bd50e.tar.gz
GhostPDF - fix Portfolio PDF with pdfwrite
No file or bug report for this, the customer requested the files be kept private. However any PDF Collection (Portfolio) file will show the problem. GhostPDF supports preserving embedded files from the input, but when we are processing a PDF Collection we don't want to do that, because in this case we run each of the embedded files individually. If we copy the EmbeddedFIles as well then we end up duplicating them in the output. So, when processing EmbeddedFiles, check the Catalog to see if there is a /Collection key, if there is then stop processing EmbeddedFiles. The customer also pointed out there was no way to avoid embedding any EmbeddedFiles from the input, so additionally add a new switch -dPreserveEmbeddedFiles to control this. While we're doing that, add one to control the preservation of 'DOCVIEW' (PageMode, PageLayout, OpenAction) as well, -dPreserveDocView. This then leads on to preventing the EmbeddedFiles in a PDF Collection from writing their DocView information. If we let them do that then we end up opening the file incorrectly. To facilitate similar changes in the future I've rejigged the way .PDFInit works, so that it calls a helper function to read any interpreter parameters and applies them to the PDF context. I've also added a new PostScript operator '.PDFSetParams' which takes a PDF context and a dictionary of key/value pairs which it applies to the context. Sadly I can't actually use that for the docview control, because the PDF initialisation is what processes the document, so changing it afterwards is no help. So I've altered runpdfbegin to call a new function runpdfbegin_with_params and pass an empty dictionary. That then allows me to call runpdfbegin_with_params from the PDF Collection processing, and turn off PreserveDocView. So in summary; new controls PreserveDocView and PreserveEmbeddedFiles and a new function .PDFSetParams to allow us to alter the PDF interpreter parameters after .PDFInit is executed. PDF Collections no longer embed duplicate files.
Diffstat (limited to 'pdf/ghostpdf.h')
-rw-r--r--pdf/ghostpdf.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/pdf/ghostpdf.h b/pdf/ghostpdf.h
index acf6b0d72..8c91ebcf6 100644
--- a/pdf/ghostpdf.h
+++ b/pdf/ghostpdf.h
@@ -137,6 +137,8 @@ typedef struct cmd_args_s {
bool preserveannots;
char **preserveannottypes; /* Null terminated array of strings, NULL if none */
bool preservemarkedcontent;
+ bool preserveembeddedfiles;
+ bool preservedocview;
bool nouserunit;
bool renderttnotdef;
bool pdfinfo;