From: Jozef M. <mis...@ho...> - 2008-05-01 10:01:22
|
hey gwurk, thx a lot. michal will be here in 2 weeks time. i put it into bugtracker that we do not forget it jozo > Date: Wed, 30 Apr 2008 19:30:49 -0400 > From: gw...@fi... > To: pdf...@li... > Subject: OldStylePdfWriter writes wrong /Size in trailer, XRef doesn't count objects correctly > > Hi again, > > I noticed a problem where PDFedit seems to write an incorrect /Size > entry in the new trailer it adds. Suppose the PDF we're editing has 5 > entries in its xref table, but only 2 are used: > > xref > 0 5 > 0000000001 65535 f > 0000000002 00001 f > 0000000000 00001 f > 0000000123 00000 n > 0000000456 00000 n > trailer << /Size 5 /Root 4 0 R >> > > In OldStylePdfWriter::writeTrailer(), we compute the new /Size as: > std::max(prevSection.objNum, (size_t)(maxObjNum + 1)) > > and prevSection.objNum is set by the caller XRefWriter::saveChanges(): > secInfo={lastXRefPos, XRef::getNumObjects()}; > > And looking at XRef::getNumObjects(), it's defined as: > virtual int getNumObjects() > { > int count=0; > for(int i=0; i<size; i++) > // counts just not free entries > if(entries[i].type != xrefEntryFree) > count++; > > return count; > } > > Notice that it just counts the number of used entries; it does not > return the number of the LAST used entry. So XRef::getNumObjects() > would return 2, even though the xref table had 5 entries. If we wrote > a new trailer with this information, it would have the wrong /Size. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Pdfedit-devel mailing list > Pdf...@li... > https://lists.sourceforge.net/lists/listinfo/pdfedit-devel _________________________________________________________________ Spell a grand slam in this game where word skill meets World Series. Get in the game. http://club.live.com/word_slugger.aspx?icid=word_slugger_wlhm_admod_april08 |