Hello,

I've received PDF file with broken page table where page count is stored as reference. Opening such file returnes zero pages instead of correct count.
There is small patch in the attachment which solves the issue.

Any comments are welcomed...

Regards, Petr Pytelka


Index: src/doc/PdfPagesTree.cpp
===================================================================
--- src/doc/PdfPagesTree.cpp    (revision 1603)
+++ src/doc/PdfPagesTree.cpp    (working copy)
@@ -71,8 +71,13 @@
 
 int PdfPagesTree::GetTotalNumberOfPages() const
 {
-    return ( ( this->GetObject()->GetDictionary().HasKey( "Count" ) ) ?
-             static_cast<int>(this->GetObject()->GetDictionary().GetKeyAsLong( 
"Count", 0LL )) : 0 );
+       const PdfObject *pObject = GetObject()->GetIndirectKey( "Count" );
+       if(pObject!=NULL) {
+               return (pObject->GetDataType()==ePdfDataType_Number) ?
+                       static_cast<int>(pObject->GetNumber()):0;
+       } else {
+               return 0;
+       }
 }
 
 PdfPage* PdfPagesTree::GetPage( int nIndex )
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to