summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Freitag <Thomas.Freitag@alfa.de>2012-12-28 01:18:48 +0100
committerAlbert Astals Cid <aacid@kde.org>2012-12-28 01:18:48 +0100
commitd61c6d4944d6f7c9e8b517dd28958124f4923d08 (patch)
tree6891b93ebed4d02d1b2eac51d52063ba44be9406
parentbe4804bff2b722ceac180da52ad436fee548f9ee (diff)
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
-rw-r--r--poppler/PDFDoc.cc6
-rw-r--r--poppler/PDFDoc.h4
-rw-r--r--utils/pdfunite.cc4
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 <kovid@kovidgoyal.net>
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2010 Srinivas Adicherla <srinivas.adicherla@geodesic.com>
-// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de>
+// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
//
// 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 <Thomas.Freitag@alfa.de>
+// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
@@ -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;
}