PdfBookmarkEditor class won't actually let me EDIT any bookmarks

No changes ever occur to bookmarks when I use PdfBookmarkEditor.


public SomeFunction( PdfBookmarkEditor be )
{
Bookmarks bks = be.ExtractBookmarks();

foreach ( Bookmark bk in bks )
bk.Title = “aaaaaaaaaaaa” + bk.Title;

be.Document.Save( @“c:\develop\output.pdf” );
}

Obviously the result of this code should be that every title has the letters “aaaaaa” in front of it. But that’s not what occurs. Nothing at all occurs.

Hi Tim,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the sample code.

I am able to generate your issue in modifying bookmarks (I also tried PdfBookmarkEditor.ModifyBookmarks method but the result is not correct). For the sake of correction, I have registered the issue in our issue tracking system with issue id: PDFNEWNET-33468 as a high priority issue. You will be notified via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

Hi Tim,


Thanks for your patience.

We have further investigated the issue reported earlier and as per our observations, there seems to be a problem related to the code snippet which you have been using. The problem here is that Bookmarks collection (bks) stores not direct Bookmark objects but only copies of that objects. So modification that copies in loop (bk.Title = “prefix_” + bk.Title) has no any effect in original document. I would suggest you to please try using the following code snippet.

[C#]

Document doc = new
Document(“doc_with_bookmarks.pdf”);<o:p></o:p>

foreach (OutlineItemCollection outline in doc.Outlines)

outline.Title = "prefix_" + outline.Title;

doc.Save(“doc_with_edited_bookmarks.pdf”);