Hello dear podofo users, I was having some issues with an unloadable pdf file. Analysing the file, I found out that Podofo does not allow a zero for the /Prev key inside the trailer dictionary:
xref 1 5 0000790024 00000 n 0000000208 00000 n 0000789878 00000 n 0000000012 00000 n 0000790084 00000 n trailer << */Prev 0* /Root 5 0 R /Size 6 >> startxref 790136 %%EOF When removing or renaming the "/Prev 0" key, podofo can load the file just fine. But then the file will no longer be loadable by Adobe Viewer. Why that happens, I don't know, especailly since Adobe can load other pdf files without any prev key without issue. So to resolve this whole issue, I created a patch that ignores the /Prev key if its value is zero. See attached patch. Greetings F.E.
--- src/podofo/base/PdfParser.cpp +++ src/podofo/base/PdfParser.cpp @@ -586,12 +586,17 @@ if( trailer.GetDictionary().HasKey( "Prev" ) ) { - // Whenever we read a Prev key, - // we know that the file was updated. - m_nIncrementalUpdates++; - try { pdf_long lOffset = static_cast<pdf_long>(trailer.GetDictionary().GetKeyAsLong( "Prev", 0 )); + if( 0 == lOffset ) + { + PdfError::LogMessage( eLogSeverity_Warning, "XRef contents at offset %" PDF_FORMAT_INT64 " is invalid, skipping the read\n", static_cast<pdf_int64>( lOffset )); + return; + } + + // Whenever we read a Prev key (!= 0), + // we know that the file was updated. + m_nIncrementalUpdates++; if( m_visitedXRefOffsets.find( lOffset ) == m_visitedXRefOffsets.end() ) ReadXRefContents( lOffset );
_______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users