Articles in this section

How to create nested bookmarks in PDF?

You can create nested bookmarks easily in PDF. Refer to the following code examples.

C#

            //Initialize the PDF document
            PdfDocument doc = new PdfDocument();
            //Set page mode
            doc.ViewerPreferences.PageMode = PdfPageMode.UseOutlines;
            //Add top level bookmark
            PdfBookmark pdfBookMark = doc.Bookmarks.Add("Top Book Mark");
            //Add a new page to PDF document
            PdfPage page = doc.Pages.Add();
            //Assign the destination
            pdfBookMark.Destination = new PdfDestination(page);
            //Add new bookmarks and destination
            PdfBookmark pageBookMark1 = pdfBookMark.Add("Page 1");
            pdfBookMark[0].Destination = new PdfDestination(page);
            pageBookMark1.Add("Quarter 1");
            pageBookMark1[0].Destination = new PdfDestination(page, new PointF(10, 200));
            pageBookMark1.Add("Quarter 2");
            pageBookMark1[1].Destination = new PdfDestination(page, new PointF(10, 400));
            pageBookMark1.Add("Quarter 3");
            pageBookMark1[2].Destination = new PdfDestination(page, new PointF(10, 600));
            // Save and close the document.
            doc.Save("Sample.pdf");
            doc.Close(true);

 

VB

        'Initialize the PDF document
        Dim doc As New PdfDocument()
        'Set page mode
        doc.ViewerPreferences.PageMode = PdfPageMode.UseOutlines
        'Add top level bookmark
        Dim pdfBookMark As PdfBookmark = doc.Bookmarks.Add("Top Book Mark")
        'Add a new page to PDF document
        Dim page As PdfPage = doc.Pages.Add()
        'Assign the destination
        pdfBookMark.Destination = New PdfDestination(page)
        'Add new bookmarks and destination
        Dim pageBookMark1 As PdfBookmark = pdfBookMark.Add("Page 1")
        pdfBookMark(0).Destination = New PdfDestination(page)
        pageBookMark1.Add("Quarter 1")
        pageBookMark1(0).Destination = New PdfDestination(page, New PointF(10, 200))
        pageBookMark1.Add("Quarter 2")
        pageBookMark1(1).Destination = New PdfDestination(page, New PointF(10, 400))
        pageBookMark1.Add("Quarter 3")
        pageBookMark1(2).Destination = New PdfDestination(page, New PointF(10, 600))
        ' Save and close the document.
        doc.Save("Sample.pdf")
        doc.Close(True)

 

Refer to the following sample link for creating the nested Bookmark.



Note:

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

 

Conclusion:

I hope you enjoyed learning about how to create nested bookmarks in PDF.

 

You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples 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 explore 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 forums 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)
Access denied
Access denied