After some digging, Chromium / Skia do not store annotations as references, but
directly as dictionnary under /Annots.
Here is a simple patch which solves it but incorrect : the allocated PdfObject
is not deleted afterwards.
----- Mail original -----
De: le...@free.fr
À: podofo-users@lists.sourceforge.net
Envoyé: Mercredi 6 Décembre 2017 10:01:58
Objet: [Podofo-users] Parse error on Chromium generated PDFs
Hello,
Thanks for this library. I try to use it to postprocess Chromium generated PDFs
(add of outlines) but a parsing error occurs on them.
Here is an exemple output of podofopdfinfo :
Page Info
---------
Page Count: 1
Page 0:
->Internal Number:1
->Object Number:5 0 R
MediaBox: [ 0.000000 0.000000 842.000000 1191.000000 ]
Rotation: 0
# of Annotations: 1
Error: An error 20 ocurred during uncompressing the pdf file.
PoDoFo encountered an error. Error: 20 ePdfError_InvalidDataType
Callstack:
#0 Error Source: ../src/base/PdfVariant.h:883
Steps to reproduce :
Open Chrome or Chromium
Go to http://example.com/
Print the page to a PDF
Execute podofopdfinfo on it
Or on command line
$ chromium-browser 'data:text/html,<a href="http://example.com">Hello
World</a>' --headless --print-to-pdf=test.pdf
$ podofopdfinfo -P test.pdf
More specifically, the problem occurs when the page contain at least a link. I
can reproduce it on a custom build of the trunk and the 0.9.3 packaged on
Ubuntu 16.04.
Best regards,
Leizh
------------------------------------------------------------------------------
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-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users
Index: src/doc/PdfPage.cpp
===================================================================
--- src/doc/PdfPage.cpp (révision 1861)
+++ src/doc/PdfPage.cpp (copie de travail)
@@ -369,21 +369,27 @@
PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
}
- ref = pObj->GetArray()[index].GetReference();
- pAnnot = m_mapAnnotations[ref];
- if( !pAnnot )
- {
- pObj = this->GetObject()->GetOwner()->GetObject( ref );
- if( !pObj )
- {
- PdfError::DebugMessage( "Error looking up object %i %i R\n", ref.ObjectNumber(), ref.GenerationNumber() );
- PODOFO_RAISE_ERROR( ePdfError_NoObject );
- }
-
- pAnnot = new PdfAnnotation( pObj, this );
- m_mapAnnotations[ref] = pAnnot;
- }
+ PdfObject variant = pObj->GetArray()[index];
+ if (variant.IsDictionary()) {
+ pAnnot = new PdfAnnotation(new PdfObject(variant), this );
+ } else {
+ ref = variant.GetReference();
+ pAnnot = m_mapAnnotations[ref];
+ if( !pAnnot )
+ {
+ pObj = this->GetObject()->GetOwner()->GetObject( ref );
+ if( !pObj )
+ {
+ PdfError::DebugMessage( "Error looking up object %i %i R\n", ref.ObjectNumber(), ref.GenerationNumber() );
+ PODOFO_RAISE_ERROR( ePdfError_NoObject );
+ }
+
+ pAnnot = new PdfAnnotation( pObj, this );
+ m_mapAnnotations[ref] = pAnnot;
+ }
+ }
+
return pAnnot;
}
------------------------------------------------------------------------------
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-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users