Articles in this section
Category / Section

How to merge PDF documents with grouped bookmarks in C# and VB.NET ?

2 mins read

The Syncfusion Essential PDF is a feature-rich and high performance .NET PDF library used to create, read, and edit PDF documents programmatically without Adobe dependencies. This library also offers functionality to merge, split, stamp, forms, compress, and secure PDF files.

This sample uses the following PDF documents and explains how to merge them with grouped bookmarks using Syncfusion .NET PDF library.

PDF document with bookmarks

PDF document with bookmarks

Steps to merge PDF documents with grouped bookmarks programmatically in C#:

  1. Create a new C# console application project. Create a console application in Visual Studio
  2. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from the NuGet.orgRefer NuGet package to the project
  3. You can merge two PDF documents by using the Merge method of PdfDocumentBase class.

C#

//Merge PDF file
PdfDocumentBase.Merge(document, loadedDocument);

 

VB.NET

'Merge PDF file
PdfDocumentBase.Merge(document, loadedDocument)

 

  1. Include the following namespaces in Program.cs file.

C#

using Syncfusion.Pdf;

 

VB.NET

Imports Syncfusion.Pdf

 

  1. Include the following code snippet in main method of Program.cs file to merge PDF documents with grouped bookmarks.

C#

//Create a new PDF document
PdfDocument finalDoc = new PdfDocument();
 
//Create a string array of source files to be merged
string[] source = { "Document1.pdf", "Document2.pdf" };
 
//Merge the PDF documents
PdfDocument.Merge(finalDoc, source);
 
//Save the PDF document
finalDoc.Save("MergedDocument.pdf");
 
//Close the instance of PdfDocument
finalDoc.Close(true);

 

VB.NET

'Create a new PDF document
Dim finalDoc As PdfDocument = New PdfDocument
 
'Create a string array of source files to be merged
Dim source() As String = {"Document1.pdf", "Document2.pdf"}
 
'Merge the PDF documents
PdfDocument.Merge(finalDoc, source)
 
'Save the PDF document
finalDoc.Save("MergedDocument.pdf")
 
'Close the instance of PdfDocument
finalDoc.Close(True)

 

A complete work sample to merge PDF documents with grouped bookmarks can be downloaded from MergePDF.zip.

By executing the program, you will get the PDF document as follows.

Merged PDF document with grouped bookmarks

Take a moment to peruse the documentation, where you will find other options like RTF to PDF conversion, XPS to PDF conversion, PDF to image conversion, HTML to MHTML, HTML to SVG, partial webpage to SVG, and more.

Click here to explore the rich set of Syncfusion Essential PDF features.

An online sample link to convert Word document to PDF, RTF to PDF, XPS to PDF, TIFF to PDF, PDF to Image, and Excel document to PDF.

See Also:

Merge all PDF files in a folder into single PDF document

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


Conclusion

I hope you enjoyed learning about how to merge PDF documents with grouped bookmarks in WinForms.

You can refer to our  WinForms FileFormat Libraries to know about its other groundbreaking feature representations and how to quickly get started for configuration specifications. You can also explore our demo to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied