Examples

Add Bookmarks and Outlines to PDFs

Allow end users to quickly navigate to specific sections or pages of a PDF using bookmarks. DynamicPDF Core Suite for .NET makes adding bookmarks and outlines to a PDF a breeze, as the following C# examples illustrate.

How to Add Bookmark to PDF

The following steps and C# sample code illustrate how to add bookmarks to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding Bookmarks to a PDF Document


  1. Create a Document object.
  2. Create three Page objects.
  3. Create a Outline as a parent object to the document.
  4. Add four top level Bookmark object instances, one for each Page instance.
  5. For each child Bookmark, specify its parent outline.
  6. Add all the pages to the Document instance.
  7. Add the Draw method to output the PDF document.

Sample Code - C#


Document document = new Document();
Page page1 = new Page( PageSize.Letter );
Page page2 = new Page( PageSize.Letter );
Page page3 = new Page( PageSize.Letter );

Outline parentOutline = document.Outlines.Add( "Parent Outline" );

page1.Elements.Add( new Bookmark( "Top level bookmark to page 1", 0, 0 ) );

page1.Elements.Add( new Bookmark( "Bookmark to page 1", 0, 0, parentOutline ) );
page2.Elements.Add( new Bookmark( "Bookmark to page 2", 0, 0, parentOutline ) );
page3.Elements.Add( new Bookmark( "Bookmark to page 3", 0, 0, parentOutline ) );

document.Pages.Add( page1 );
document.Pages.Add( page2 );
document.Pages.Add( page3 );

document.Draw(@"Output.pdf");        

A PDF with bookmarks.

How to Add Outline to PDF

The following steps and C# sample code show how to add outlines to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding Outlines to a PDF Document


  1. Create a Document object.
  2. Create three Page objects.
  3. Create an Outline instance and add it the the Document object's Outlines collection.
  4. Create two child outlines and add them to the parent outline..
  5. Add the Draw method to output the PDF document.

Sample Code - C#


Document document = new Document();
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));
document.Pages.Add(new Page(PageSize.Letter));

Outline outline1 = document.Outlines.Add( "Outline1" );
outline1.Style = TextStyle.Bold;
outline1.Color = new RgbColor( 1.0f, 0.0f, 0.0f );

Outline outline1A = outline1.ChildOutlines.Add( "Outline1A", new ZoomDestination( 2, PageZoom.FitPage ) );
outline1A.Expanded = false;
Outline outline1A1 = outline1A.ChildOutlines.Add( "Outline1A1", new XYDestination( 2, 0, 0 ) );
Outline outline1A2 = outline1A.ChildOutlines.Add( "Outline1A2", new ZoomDestination( 2, PageZoom.FitHeight ) );
Outline outline1B = outline1.ChildOutlines.Add( "Outline1B", new ZoomDestination( 2, PageZoom.FitWidth ) );

Outline outline2 = document.Outlines.Add( "Outline2", new XYDestination( 3, 0, 300 ) );
Outline outline2A = outline2.ChildOutlines.Add( "Outline2A" );

document.Draw(@"Output.pdf");        

A PDF with bookmarks illustrating using Outline class.

GitHub Project

An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub


Clone or View Example Project on GitHub

Getting Started

Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing the product.


NuGet Package


The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information


DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!



More Information on Outlines and Bookmarks


Available on Other Platforms

DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.


Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!