Discussion:
[Podofo-users] trunk does not report correct number of annotations
Florian Hänel
2017-06-02 09:58:59 UTC
Permalink
between 0.9.5 and trunk, podofo stopped reporting the correct number of
annotations:

#include <iostream>
#include "podofo/podofo.h"

int main(int argc, char** argv) {
PoDoFo::PdfMemDocument* doc = new PoDoFo::PdfMemDocument();
doc->Load("test2-annotated.pdf");
for(int pn = 0; pn < doc->GetPageCount(); pn++) {
auto page = doc->GetPage(pn);
int num = page->GetNumAnnots();
std::cout<<"page"<<pn<<"annotations:"<<num<<std::endl;
}
}

⌘ [/home/florian/work] $ g++ -g -O0 -fno-omit-frame-pointer -std=gnu++11
podofotest.cpp -L build-podofo-trunk/src -l podofo -I podofo-trunk -I
build-podofo-trunk -DNOTCALLED -o test-trunk

⌘ [/home/florian/work] $ g++ -g -O0 -fno-omit-frame-pointer -std=gnu++11
podofotest.cpp -L build-podofo-0.9.5/src -l podofo -I podofo-0.9.5 -I
build-podofo-0.9.5 -DNOTCALLED -o test-0.9.5


⌘ [/home/florian/work] $ LD_LIBRARY_PATH=build-podofo-trunk/src
./test-trunk | grep annotations
WARNING: There are more objects (4) in this XRef table than specified in
the size key of the trailer directory (1)!
WARNING: There are more objects (126) in this XRef table than specified
in the size key of the trailer directory (4)!
<</ID[(▒^��"Mʄ����)(���cE�䵳 F�|�L)]/Info 115 0 R/Prev 2380581/Root 114 0
R/Size 126>>
page0annotations:0
page1annotations:3
page2annotations:5
page3annotations:5
page4annotations:8
page5annotations:11
page6annotations:12

⌘ [/home/florian/work] $ LD_LIBRARY_PATH=build-podofo-0.9.5/src
./test-0.9.5 | grep annotations
<</ID[(▒^��"Mʄ����)(���cE�䵳 F�|�L)]/Info 115 0 R/Prev 2380581/Root 114 0
R/Size 126>>
page0annotations:9
page1annotations:3
page2annotations:5
page3annotations:5
page4annotations:8
page5annotations:11
page6annotations:12
⌘ [/home/florian/work] $


the file was created with:

pdftk test.pdf cat 9-15 output test2.pdf

then annotated in okular on page 0

http://heeen.de/test2-annotated.pdf


Florian
zyx
2017-06-02 10:55:27 UTC
Permalink
Post by Florian Hänel
WARNING: There are more objects (4) in this XRef table than specified
in the size key of the trailer directory (1)!
WARNING: There are more objects (126) in this XRef table than
specified in the size key of the trailer directory (4)!
Hi,
the file you have seems to be broken. Could you test with a valid and
fully compliant PDF file, please?
Bye,
zyx
--
http://www.litePDF.cz ***@litePDF.cz
Mark Rogers
2017-06-07 17:03:05 UTC
Permalink
The patch for ReadXRefSubsection in r1840 has broken PDFs that contain XRef subsections.

- At r1839 m_offsets.resize was only called if m_offsets needed to grow
- At r1840 m_offsets.resize is always called which means it can shrink the m_offsets table and wipe out existing objects

For http://heeen.de/test2-annotated.pdf then r1839 did this

1) PdfParser::ReadDocumentStructure resizes m_offsets table to 126 objects, then reads into m_offsets
2) Doesn’t resize m_offsets in PdfParser::ReadXRefSubsection (already big enough)
3) Doesn’t resize m_offsets in PdfParser::ReadXRefSubsection (already big enough)

For http://heeen.de/test2-annotated.pdf then r1840 does this:

1) PdfParser::ReadDocumentStructure resizes m_offsets table to 126 objects, then reads into m_offsets
2) Resizes m_offsets to 1 in PdfParser::ReadXRefSubsection (this wipes out most of the objects)
3) Resizes m_offsets to 4 in PdfParser::ReadXRefSubsection

The example in H.7.1 on page 712 of PDF32000_2008.pdf shows the problem – the first xref subsection has nFirstObject=0, nNumObjects=1, so ReadXRefSubsection calls m_offsets.resize(1) which wipes out the previously read objects (4, 7, 8, 9, 10 and 11)

Best Regards
Mark

Mark Rogers - ***@powermapper.com
PowerMapper Software Ltd - www.powermapper.com
Registered in Scotland No 362274 Quartermile 2 Edinburgh EH3 9GL
Post by Florian Hänel
WARNING: There are more objects (4) in this XRef table than specified
in the size key of the trailer directory (1)!
WARNING: There are more objects (126) in this XRef table than
specified in the size key of the trailer directory (4)!
Hi,
the file you have seems to be broken. Could you test with a valid and
fully compliant PDF file, please?
Bye,
zyx

--
http://www.litePDF.cz ***@litePDF.cz

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Loading...