[poppler] poppler/PDFDoc.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Wed Apr 7 12:11:00 PDT 2010


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

New commits:
commit f5dd5be64d09186ee289632c1a61979d15edd605
Author: Carlos Garcia Campos <carlosgc at gnome.org>
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 <aacid at kde.org>
 // Copyright (C) 2008 Julien Rebetez <julienr at svn.gnome.org>
 // Copyright (C) 2008 Pino Toscano <pino at kde.org>
-// Copyright (C) 2008 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2008, 2010 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2009 Eric Toombs <ewtoombs at uwaterloo.ca>
 // Copyright (C) 2009 Kovid Goyal <kovid at kovidgoyal.net>
 // Copyright (C) 2009 Axel Struebing <axel.struebing at freenet.de>
@@ -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;
 }


More information about the poppler mailing list