From d61c6d4944d6f7c9e8b517dd28958124f4923d08 Mon Sep 17 00:00:00 2001 From: Thomas Freitag Date: Fri, 28 Dec 2012 01:18:48 +0100 Subject: Repair pdfunite Sorry, when I implemented the support encrypted pdf files in pdfseparate I missed that writePageObjects of course is also used in pdfunite for combining pages, and even more that encrypted files are still not supported by pdfunite, I removed the numoffset from writing the objects itself. Therefore there are still all objects in the combined pdf file, but the references missing the numoffset and therefore were no more reachable. The patch repairs it. Bug #58569 --- poppler/PDFDoc.cc | 6 ++++-- poppler/PDFDoc.h | 4 ++-- utils/pdfunite.cc | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index f307890a..0d78588c 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -1526,7 +1526,7 @@ void PDFDoc::markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint n } } -Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset) +Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, GBool combine) { Guint objectsCount = 0; //count the number of objects in the XRef(s) Guchar *fileKey; @@ -1543,7 +1543,9 @@ Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset) objectsCount++; getXRef()->fetch(ref.num - numOffset, ref.gen, &obj); Guint offset = writeObjectHeader(&ref, outStr); - if (xRef->getEntry(n)->getFlag(XRefEntry::Unencrypted)) { + if (combine) { + writeObject(&obj, outStr, getXRef(), numOffset, NULL, cryptRC4, 0, 0, 0); + } else if (xRef->getEntry(n)->getFlag(XRefEntry::Unencrypted)) { writeObject(&obj, outStr, NULL, cryptRC4, 0, 0, 0); } else { writeObject(&obj, outStr, fileKey, encAlgorithm, keyLength, ref.num, ref.gen); diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index f3e9f68b..45623465 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -22,7 +22,7 @@ // Copyright (C) 2009 Kovid Goyal // Copyright (C) 2010 Hib Eris // Copyright (C) 2010 Srinivas Adicherla -// Copyright (C) 2011 Thomas Freitag +// Copyright (C) 2011, 2012 Thomas Freitag // Copyright (C) 2012 Fabio D'Urso // // To see a description of the changes please see the Changelog file that @@ -243,7 +243,7 @@ public: void replacePageDict(int pageNo, int rotate, PDFRectangle *mediaBox, PDFRectangle *cropBox, Object *pageCTM); void markPageObjects(Dict *pageDict, XRef *xRef, XRef *countRef, Guint numOffset); // write all objects used by pageDict to outStr - Guint writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset); + Guint writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset, GBool combine = gFalse); static void writeObject (Object *obj, OutStream* outStr, XRef *xref, Guint numOffset, Guchar *fileKey, CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen); static void writeHeader(OutStream *outStr, int major, int minor); diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc index 65022599..79d05f04 100644 --- a/utils/pdfunite.cc +++ b/utils/pdfunite.cc @@ -4,7 +4,7 @@ // // This file is licensed under the GPLv2 or later // -// Copyright (C) 2011 Thomas Freitag +// Copyright (C) 2011, 2012 Thomas Freitag // Copyright (C) 2012 Arseny Solokha // Copyright (C) 2012 Fabio D'Urso // Copyright (C) 2012 Albert Astals Cid @@ -122,7 +122,7 @@ int main (int argc, char *argv[]) Dict *pageDict = page.getDict(); docs[i]->markPageObjects(pageDict, yRef, countRef, numOffset); } - objectsCount += docs[i]->writePageObjects(outStr, yRef, numOffset); + objectsCount += docs[i]->writePageObjects(outStr, yRef, numOffset, gTrue); numOffset = yRef->getNumObjects() + 1; } -- cgit v1.2.3