Hi,
It seems difficult to remove pages from this doc*.
I fixed some segfaults but can't figure out where, exactly, lies the problem.
* http://www.gutenberg.eu.org/pub/GUTenberg/publicationsPDF/26-bouche.pdf
--
Pierre Marchand
Index: src/PdfPagesTree.cpp
===================================================================
--- src/PdfPagesTree.cpp (révision 670)
+++ src/PdfPagesTree.cpp (copie de travail)
@@ -387,8 +387,16 @@
thePageObj->GetDictionary().RemoveKey( PdfName( "Parent" ) );
PdfObject* theKidsArray = GetKids( theParentPagesDict ) ;
- PdfArray& kArr = theKidsArray->GetArray();
- kArr.erase( kArr.begin() + theIndexInKidsArray );
+ if(NULL != theKidsArray)
+ {
+ PdfArray& kArr = theKidsArray->GetArray();
+ kArr.erase( kArr.begin() + theIndexInKidsArray );
+ }
+ else
+ {
+ PdfError::DebugMessage( "Cannot find kids array where I'm supposed to be referenced\n");
+ PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
+ }
}
else if( !isPageALeaf )
{
@@ -400,7 +408,14 @@
PdfObject& oneChild = kArr[0];
int indexInKArr = GetPosInKids( thePageObj );
PdfObject* theKidsArray = GetKids( theParentPagesDict );
- oneChild.GetDictionary().AddKey( PdfName( "Parent" ), theParentPagesDict );
+ if(oneChild.IsDictionary())
+ oneChild.GetDictionary().AddKey( PdfName( "Parent" ), theParentPagesDict );
+ else if(oneChild.IsReference())
+ {
+ PdfObject* oneChildInd = theParentPagesDict->GetOwner()->GetObject(oneChild.GetReference());
+ oneChildInd->GetDictionary().AddKey( PdfName( "Parent" ), theParentPagesDict );
+ }
+
theKidsArray->GetArray()[ indexInKArr ] = oneChild;
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users