summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSune Vuorela <sune@vuorela.dk>2024-04-03 14:30:12 +0200
committerAlbert Astals Cid <aacid@kde.org>2024-04-20 10:52:34 +0000
commit081352cf9fa600c68ee1bebc457cee88fed6f94d (patch)
treed8f2dd2e67d757c0d6b09bd9f1365d2ae8fd35d0
parentc5684e7697a070d7ecdf4114788ae76d57ef18b2 (diff)
pdftops: Write compliant ps header
According to the postscript spec, only DSC Comments are allowed in the header. %%Creator is the header for the software used to generate the postscript file, which is pdftops in this case, and not as such the generator for the pdf file. I've chosen to, if available, keep the pdf creator as a substring in the %%Creator field. Originates in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1068307
-rw-r--r--poppler/PSOutputDev.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 8828ac73..33f3d2f6 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -84,6 +84,7 @@
#include "SplashOutputDev.h"
#include "PSOutputDev.h"
#include "PDFDoc.h"
+#include "UTF.h"
#ifdef USE_CMS
# include <lcms2.h>
@@ -1569,15 +1570,24 @@ void PSOutputDev::writeHeader(int nPages, const PDFRectangle *mediaBox, const PD
writePS("%!PS-Adobe-3.0 Resource-Form\n");
break;
}
- writePSFmt("%Produced by poppler pdftops version: {0:s} (http://poppler.freedesktop.org)\n", PACKAGE_VERSION);
Object info = xref->getDocInfo();
+ std::unique_ptr<GooString> creator = GooString::format("poppler pdftops version: {0:s} (http://poppler.freedesktop.org)", PACKAGE_VERSION);
if (info.isDict()) {
Object obj1 = info.dictLookup("Creator");
if (obj1.isString()) {
- writePS("%%Creator: ");
- writePSTextLine(obj1.getString());
+ const GooString *pdfCreator = obj1.getString();
+ if (pdfCreator && !pdfCreator->toStr().empty()) {
+ creator->append(". PDF Creator: ");
+ if (pdfCreator->hasUnicodeMarker()) {
+ creator->append(TextStringToUtf8(pdfCreator->toStr()));
+ } else {
+ creator->append(pdfCreator);
+ }
+ }
}
}
+ writePS("%%Creator: ");
+ writePSTextLine(creator.get());
if (title) {
char *sanitizedTitle = strdup(title);
for (size_t i = 0; i < strlen(sanitizedTitle); ++i) {