Hello dear podofo users, I stumbled upon an issue with the deletion of annotations today:
PdfPage.cpp:409ff > void PdfPage::DeleteAnnotation( int index ) > { > PdfObject* pObj = this->GetAnnotationsArray( false ); > PdfObject* pItem; > [..] > pItem = &(pObj->GetArray()[index]); > if( pItem->IsDictionary() ) > { > [..] > } > else > { > this->DeleteAnnotation( pItem->GetReference() ); > } > } > When calling DeleteAnnotation with an index, the requested Annotation is stored into pItem. In my case it is not a dictionary, so DeleteAnnotation with a Reference is called: PdfPage.cpp:446ff > void PdfPage::DeleteAnnotation( const PdfReference & ref ) > { > [..] > while( it != pObj->GetArray().end() ) > { > if( (*it).IsReference() && (*it).GetReference() == ref ) > { > pObj->GetArray().erase( it ); > bFound = true; > break; > } > ++it; > } > [..] > delete this->GetObject()->GetOwner()->RemoveObject( ref ); > } > Here, the reference is removed from the array and the corresponding object is deleted at the end. *The problem is, the erase operation on the array destroys the reference ref! *I can see with the debugger that Ref's object number changes after the erase, so the subsequent RemoveObject call is in error! It either tries to remove a non-existing object (best-case) or some other unrelated object (worst-case), depending on what values are stored at the location now. When checking the resulting PDF, I can see that the annotation objects are still there, but it was removed from the page's annotation list. I guess the fix might be quite easy: Either pass the PdfReference by value instead of by reference, or copy it into a local before removing it from the array, so a valid PdfReference object can be used for subsequent removal. I didn't have time to test this myself today, though. Could someone confirm my findings, please? Greetings F.E. p.s.: Sorry for the first, uncomplete mail, didn't know gmail sends the mail right away when pressing CTRL+Enter
_______________________________________________ Podofo-users mailing list Podofo-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/podofo-users