Am 11.03.2014 08:50, schrieb zyx:
By the way, would you mind to look on AESv3 too?
Maybe yes, if I find some time for it.
But before I have an other patch:
My last patch should handle multiple XRef object for encrypted PDFs. But it breaks merged unencryted PDFs with multiple XRef objects.
So instead of not adding XRef object to m_vecObjects, this patch sets the encryption to NULL for these objects.

Bye

Andreas
--

dots

Andreas Brzesowsky

dots Software GmbH
Schlesische Str. 27, 10997 Berlin, Germany
Phone: +49 (0)30 695 799-34, Fax: +49 (0)30 695 799-55

andreas.brzesow...@dots.de
http://www.dots.de

Amtsgericht (District Court): Berlin Charlottenburg HRB 65201
Geschäftsführer (Managing Directors): Olaf Lorenz, Ken Osuga

Follow us on: Twitter Youtube Xing
Index: src/base/PdfParser.cpp
===================================================================
--- src/base/PdfParser.cpp      (revision 1584)
+++ src/base/PdfParser.cpp      (working copy)
@@ -955,16 +955,10 @@
     int              i            = 0;
     int              nLast        = 0;
     PdfParserObject* pObject      = NULL;
-    int              trailerObjNo = m_pTrailer->Reference().ObjectNumber();
 
     // Read objects
     for( i=0; i < m_nNumObjects; i++ )
     {
-        // Never add the XRef/Trailer to m_vecObjects
-               // (For AESV2 the XRef has cUsed == 'n' and XRef stream is not 
encrypted.
-               //  So setting m_pEncrypt for it would throw exception if the 
stream is read later on.)
-               if (i == trailerObjNo)
-                       continue;
 #ifdef PODOFO_VERBOSE_DEBUG
                std::cerr << "ReadObjectsInteral\t" << i << " "
                        << (m_offsets[i].bParsed ? "parsed" : "unparsed") << " "
@@ -979,13 +973,16 @@
             pObject = new PdfParserObject( m_vecObjects, m_device, m_buffer, 
m_offsets[i].lOffset );
             pObject->SetLoadOnDemand( m_bLoadOnDemand );
             try {
-                pObject->ParseFile( m_pEncrypt );
-                               PdfObject* pObjType = pObject->IsDictionary() ? 
pObject->GetDictionary().GetKey( PdfName::KeyType ) : 0;
-                               if( pObjType && pObjType->IsName() && 
pObjType->GetName() == "XRef" ) {
-                                       // Never add the XRef to m_vecObjects 
because if it has a stream it is not encrypted
-                                       // (So setting m_pEncrypt for it would 
throw exception if the stream is read later on.)
-                                       delete pObject;
-                                       continue;
+                               pObject->ParseFile( m_pEncrypt );
+                               if (m_pEncrypt && pObject->IsDictionary()) {
+                                       PdfObject* pObjType = 
pObject->GetDictionary().GetKey( PdfName::KeyType );
+                                       if( pObjType && pObjType->IsName() && 
pObjType->GetName() == "XRef" ) {
+                                               // XRef is never encrypted
+                                               delete pObject;
+                                               pObject = new PdfParserObject( 
m_vecObjects, m_device, m_buffer, m_offsets[i].lOffset );
+                                               pObject->SetLoadOnDemand( 
m_bLoadOnDemand );
+                                               pObject->ParseFile( NULL );
+                                       }
                                }
                 nLast = pObject->Reference().ObjectNumber();
 
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to