[poppler] poppler/PDFDoc.cc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Oct 21 15:41:12 UTC 2018


 poppler/PDFDoc.cc |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit fdea0c5c03fac42c783b7f134c153dc9db0a5262
Author: Philipp Knechtges <philipp-dev at knechtges.com>
Date:   Sun Oct 21 16:58:11 2018 +0200

    Adjust pdf writing to honor PDF/A rules
    
    PDF/A as can be tested with VeraPDF requires:
    - Second line needs to be a comment line with four characters with byte encoding above 127
    - "obj" needs to be followed by a new line
    - "endobj" needs to start on a new line

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index e7cf65f5..80d3f808 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -41,6 +41,7 @@
 // Copyright (C) 2018 Evangelos Foutras <evangelos at foutrelis.com>
 // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info at kdab.com>. Work sponsored by the LiMux project of the city of Munich
 // Copyright (C) 2018 Evangelos Rigas <erigas at rnd2.org>
+// Copyright (C) 2018 Philipp Knechtges <philipp-dev at knechtges.com>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -1179,7 +1180,7 @@ void PDFDoc::saveCompleteRewrite (OutStream* outStr)
   int keyLength;
   xref->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength);
 
-  outStr->printf("%%PDF-%d.%d\r\n",pdfMajorVersion,pdfMinorVersion);
+  writeHeader(outStr, getPDFMajorVersion(), getPDFMinorVersion());
   XRef *uxref = new XRef();
   uxref->add(0, 65535, 0, gFalse);
   xref->lock();
@@ -1357,7 +1358,7 @@ void PDFDoc::writeString (const GooString* s, OutStream* outStr, const Guchar *f
 Goffset PDFDoc::writeObjectHeader (Ref *ref, OutStream* outStr)
 {
   Goffset offset = outStr->getPos();
-  outStr->printf("%i %i obj ", ref->num, ref->gen);
+  outStr->printf("%i %i obj\r\n", ref->num, ref->gen);
   return offset;
 }
 
@@ -1508,7 +1509,7 @@ void PDFDoc::writeObject (Object* obj, OutStream* outStr, XRef *xRef, Guint numO
 
 void PDFDoc::writeObjectFooter (OutStream* outStr)
 {
-  outStr->printf("endobj\r\n");
+  outStr->printf("\r\nendobj\r\n");
 }
 
 Object PDFDoc::createTrailerDict(int uxrefSize, GBool incrUpdate, Goffset startxRef,


More information about the poppler mailing list