See also,
http://www.aspose.com/community/forums/372183/cannot-delete-pages-and-also-bookmarks/showthread.aspx#372183
PdfBookmarkEditor’s two functions, ExtractBookmarks and CreateBookmarks are inconsistent.
For example:
Bookmarks bks = be.ExtractBookmarks(); // let's say this returns a collection of 50 bookmarks
be.DeleteBookmarks(); // now there are 0 bookmarks
foreach ( Bookmark bk in bks )
be.CreateBookmarks( bk );
// now the count should be 50 bookmarks, right?
The answer is… it depends.
If the original bookmarks were structured like this…
A
-
A1
-
A2
B
-
B1
-
B2
… the bookmark collection will have a size of 6 when Extracted.
When I do a foreach to recreate them, however, 10 bookmarks will be inserted, because…
A is created with A1 and A2
A1 is created
A2 is created
B is imported with B1 and B2
B1 is created
B2 is created
I cannot imagine this is by design. I think your options are:
-
ExtractBookmarks needs a boolean in an overload that says to get children or not
-
ExtractBookmarks needs better intellisense
-
Both
Further, it is unclear if I’m making changes to A1 in the original collection, if the first ChildItem in A.ChildItem is also modified, since this is the same object.
PdfBookmarkEditor is poorly implemented.