How can I merge multi pdf files with bookmarks?

Hi, 

I'm using .NET 8 and syncfusion 25.1.35. 

I've attempted to merge multi pdf files. How could I merge with bookmarks handling options such as: merging all bookmarks from input files,  creating new bookmarks from them, removing all bookmarks. 

I've not see any options when merge them.

btw, I've not  see any options to optimize the output file's quality such as : web ready (small), office ready (medium), print ready (large) too.

P/s: The merge options, which I've mentioned, look like in the Nitro PDF application. 

Thanks and best regards,

TH



3 Replies

JT Jeyalakshmi Thangamarippandian Syncfusion Team May 28, 2024 09:57 AM UTC

Hi Thanh Hai Dang,

We have created a sample for merging PDF documents with bookmarks. The sample is attached for your reference. We kindly request you to try it out and let us know if you require any further assistance.

Sample link:

https://www.syncfusion.com/downloads/support/directtrac/general/ze/MauiGrid-1118536696.zip

Please refer to the UG documentation for further details:

Merge PDF Documents | Syncfusion

Working with Bookmarks | PDF library | Syncfusion


Regards,

Jeyalakshmi T



TH Thanh Hai Dang replied to Jeyalakshmi Thangamarippandian June 9, 2024 02:22 PM UTC

Hi  Jeyalakshmi ,

Thank you for spending time with my requirements. However, I cannot show anything about bookmarks in your example. 

See the example created for save pdf file in the others format.

Thanks 



JT Jeyalakshmi Thangamarippandian Syncfusion Team June 10, 2024 12:10 PM UTC

Hi Thanh Hai Dang,

We have created a sample for creating new bookmarks in a PDF. Kindly refer to the code snippet for your reference:

PdfDocument finalDocument = new PdfDocument();

Stream documentStream = this.GetType().Assembly.GetManifestResourceStream("MauiGrid.Resources.Pdf.sample.pdf");

Stream documentStream2 = this.GetType().Assembly.GetManifestResourceStream("MauiGrid.Resources.Pdf.Input.pdf");

          

//Create a PDF stream for merging

Stream[] streams = { documentStream, documentStream2 };

          

PdfMergeOptions mergeOptions = new PdfMergeOptions();

mergeOptions.OptimizeResources = true;

//Merge PDF documents

PdfDocumentBase.Merge(finalDocument,mergeOptions, streams);

 

PdfBookmark bookmark = finalDocument.Bookmarks.Add("Page 1");

//Sets the destination page.

bookmark.Destination = new PdfDestination(finalDocument.Pages[0]);

//Sets the text style and color.

bookmark.TextStyle = PdfTextStyle.Bold;

//Sets the destination location.

bookmark.Destination.Location = new PointF(20, 20);


We support removing bookmarks from PDF documents, and you can refer to the UG and KB documentation, as well as blogs, for further details: 

Working with Bookmarks | PDF library | Syncfusion

https://support.syncfusion.com/kb/article/8422/how-to-delete-bookmarks-from-a-pdf-using-c-and-vbnet

https://www.syncfusion.com/blogs/post/bookmarks-in-pdf-csharp


See the example created for save pdf file in the others format.

Could you please share the clear details with us. It will help us analyze and assist you further

 


Regards,

Jeyalakshmi T


Loader.
Up arrow icon