Good morning dear podofo-community,

I am quite new to Podofo, but In the last weeks I spend a lot of time with PDF 
generation. I found an error in the call "PdfVecObject" affecting the use of 
PdfStreamed documents in combination with XObjects.

Problem:

I tried to put a PDF-Document inside my new PDF-document without any problems. 
But when I tried the same on the second page, the PDF document was corrupted. 
So I had a closer look at the PDF-structure generated by Podofo and I 
recognized, that there were two PDF-objects with the same Object-ID. But this 
only happened when I tried it with the PdfStreamedDocument. With the 
PdfMemDocument there was no problem. After all I found out that the error 
occurred because objects were deleted from the PdfVecObject-vector. When the 
method "PdfDocument::Append(..)" tried to append the objects from the second 
PDF-file, it starts with the wrong Object-number. This is because it uses the 
method "m_vecObjects.GetSize()"" but this methods returns the total number of 
current objects inside the vector, but when objects have been deleted before, 
not the sequential number will be returned (needed for a unique object-number).

Inside the PdfVecObjects-the call must look like:

unsigned int difference = static_cast<unsigned 
int>(m_vecObjects.GetObjectCount())                             //__ CORRECT

instead of:

unsigned int difference = static_cast<unsigned int>(m_vecObjects.GetSize() + 
m_vecObjects.GetFreeObjects().size());                                          
 //__ WRONG


This must be applied to following methods:

PdfDocument::InsertExistingPageAt(...)
PdfDocument::Append(...)
PdfDocument::FillXObjectFromDocumentPage(...)

Best regards

Hendrik
------------------------------------------------------------------------------
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to