We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Rearrange Pdf Bookmark

Hi,
I want to re-arrange my pdf bookmark name. but i cant find solution to swap bookmark name. Can anyone help me?
In advance, Thank you.

1 Reply

MN Meikanda Nayanar Syncfusion Team April 16, 2019 04:49 PM UTC

Hi Marcus,

 

Greetings from Syncfusion.

 

Please find the code snippet for swapping the bookmark name in the PdfLoadedDocument:

 

//Loads the PDF document.

PdfLoadedDocument document = new PdfLoadedDocument(DataPathOutput + "Output.pdf");

 

//Gets all the bookmarks.

PdfBookmarkBase bookmarks = document.Bookmarks;

 

//Gets the first two bookmark and its Title.

PdfLoadedBookmark bookmark1 = bookmarks[0] as PdfLoadedBookmark;

string title1 = bookmark1.Title;

 

PdfLoadedBookmark bookmark2 = bookmarks[1] as PdfLoadedBookmark;

string title2 = bookmark2.Title;

 

//Swapping the title name of the first two bookmarks

bookmark1.Title = title2;

bookmark2.Title = title1;

 

//Saves the document

 

document.Save(DataPathOutput+"modified.pdf");

 

Sample for the same can be downloaded from below link:

http://www.syncfusion.com/downloads/support/forum/144028/ze/BookMarkSwap1050178903

 

Please let us know if you need any further assistance in this.

 

Thanks

Meikandan


Loader.
Live Chat Icon For mobile
Up arrow icon