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

New commits:
commit f5dd5be64d09186ee289632c1a61979d15edd605
Author: Carlos Garcia Campos <[email protected]>
Date:   Wed Apr 7 19:48:39 2010 +0200

    Fix saving update docs that have a compressed xref table
    
     - Use the original xref table size as Size field in the trailer
       dictionary to make sure size = maxObjId + 1
    
     - Use the right generation number for compressed objects that which
       must be 0. gen field in xref entry for compressed objects is the
       index of the object in the stream, not the generation number.
    
    Fixes bug #27450.

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index 78b6593..9505639 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -17,7 +17,7 @@
 // Copyright (C) 2005, 2007-2009 Albert Astals Cid <[email protected]>
 // Copyright (C) 2008 Julien Rebetez <[email protected]>
 // Copyright (C) 2008 Pino Toscano <[email protected]>
-// Copyright (C) 2008 Carlos Garcia Campos <[email protected]>
+// Copyright (C) 2008, 2010 Carlos Garcia Campos <[email protected]>
 // Copyright (C) 2009 Eric Toombs <[email protected]>
 // Copyright (C) 2009 Kovid Goyal <[email protected]>
 // Copyright (C) 2009 Axel Struebing <[email protected]>
@@ -544,17 +544,16 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr)
 
   uxref = new XRef();
   uxref->add(0, 65535, 0, gFalse);
-  int objectsCount = 0; //count the number of objects in the XRef(s)
   for(int i=0; i<xref->getNumObjects(); i++) {
     if ((xref->getEntry(i)->type == xrefEntryFree) && 
         (xref->getEntry(i)->gen == 0)) //we skip the irrelevant free objects
       continue;
-    objectsCount++;
+
     if (xref->getEntry(i)->updated) { //we have an updated object
       Object obj1;
       Ref ref;
       ref.num = i;
-      ref.gen = xref->getEntry(i)->gen;
+      ref.gen = xref->getEntry(i)->type == xrefEntryCompressed ? 0 : 
xref->getEntry(i)->gen;
       xref->fetch(ref.num, ref.gen, &obj1);
       Guint offset = writeObject(&obj1, &ref, outStr);
       uxref->add(ref.num, ref.gen, offset, gTrue);
@@ -569,7 +568,7 @@ void PDFDoc::saveIncrementalUpdate (OutStream* outStr)
   Guint uxrefOffset = outStr->getPos();
   uxref->writeToFile(outStr, gFalse /* do not write unnecessary entries */);
 
-  writeTrailer(uxrefOffset, objectsCount, outStr, gTrue);
+  writeTrailer(uxrefOffset, xref->getSize(), outStr, gTrue);
 
   delete uxref;
 }
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to