poppler/PDFDoc.cc |   40 +++++++++++++++++++++-------------------
 poppler/PDFDoc.h  |    4 ++--
 utils/pdfunite.cc |    4 ++--
 3 files changed, 25 insertions(+), 23 deletions(-)

New commits:
commit d61c6d4944d6f7c9e8b517dd28958124f4923d08
Author: Thomas Freitag <[email protected]>
Date:   Fri Dec 28 01:18:48 2012 +0100

    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

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index f307890..0d78588 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 f3e9f68..4562346 100644
--- a/poppler/PDFDoc.h
+++ b/poppler/PDFDoc.h
@@ -22,7 +22,7 @@
 // Copyright (C) 2009 Kovid Goyal <[email protected]>
 // Copyright (C) 2010 Hib Eris <[email protected]>
 // Copyright (C) 2010 Srinivas Adicherla <[email protected]>
-// Copyright (C) 2011 Thomas Freitag <[email protected]>
+// Copyright (C) 2011, 2012 Thomas Freitag <[email protected]>
 // Copyright (C) 2012 Fabio D'Urso <[email protected]>
 //
 // 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 6502259..79d05f0 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 <[email protected]>
+// Copyright (C) 2011, 2012 Thomas Freitag <[email protected]>
 // Copyright (C) 2012 Arseny Solokha <[email protected]>
 // Copyright (C) 2012 Fabio D'Urso <[email protected]>
 // Copyright (C) 2012 Albert Astals Cid <[email protected]>
@@ -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;
   }
 
commit be4804bff2b722ceac180da52ad436fee548f9ee
Author: Albert Astals Cid <[email protected]>
Date:   Fri Dec 28 01:17:14 2012 +0100

    dos2unix

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 5c3535d..f307890 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -610,15 +610,15 @@ int PDFDoc::savePageAs(GooString *name, int pageNo)
   OutStream *outStr;
   XRef *yRef, *countRef;
   int rootNum = getXRef()->getNumObjects() + 1;
-
-  // Make sure that special flags are set, because we are going to read
-  // all objects, including Unencrypted ones.
-  xref->scanSpecialFlags();
-
-  Guchar *fileKey;
-  CryptAlgorithm encAlgorithm;
-  int keyLength;
-  xref->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength);
+
+  // Make sure that special flags are set, because we are going to read
+  // all objects, including Unencrypted ones.
+  xref->scanSpecialFlags();
+
+  Guchar *fileKey;
+  CryptAlgorithm encAlgorithm;
+  int keyLength;
+  xref->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength);
 
   if (pageNo < 1 || pageNo > getNumPages()) {
     error(errInternal, -1, "Illegal pageNo: {0:d}({1:d})", pageNo, 
getNumPages() );
@@ -1529,10 +1529,10 @@ void PDFDoc::markPageObjects(Dict *pageDict, XRef 
*xRef, XRef *countRef, Guint n
 Guint PDFDoc::writePageObjects(OutStream *outStr, XRef *xRef, Guint numOffset) 
 {
   Guint objectsCount = 0; //count the number of objects in the XRef(s)
-  Guchar *fileKey;
-  CryptAlgorithm encAlgorithm;
-  int keyLength;
-  xRef->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength);
+  Guchar *fileKey;
+  CryptAlgorithm encAlgorithm;
+  int keyLength;
+  xRef->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength);
 
   for (int n = numOffset; n < xRef->getNumObjects(); n++) {
     if (xRef->getEntry(n)->type != xrefEntryFree) {
@@ -1543,11 +1543,11 @@ 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)) {
-        writeObject(&obj, outStr, NULL, cryptRC4, 0, 0, 0);
-      } else {
-        writeObject(&obj, outStr, fileKey, encAlgorithm, keyLength, ref.num, 
ref.gen);
-      }
+      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);
+      }
       writeObjectFooter(outStr);
       xRef->add(ref.num, ref.gen, offset, gTrue);
       obj.free();
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to