Add outlines (bookmarks) tree into existing PDF using the ByteScout PDF SDK for .NET - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

Add outlines (bookmarks) tree into existing PDF using the ByteScout PDF SDK for .NET

  • Home
  • /
  • Articles
  • /
  • Add outlines (bookmarks) tree into existing PDF using the ByteScout PDF SDK for .NET
How to add outlines/bookmarks tree into existing PDF document

This sample provides a code to show how to open existing PDF document and add outlines (bookmarks) tree to the document and then save this modified document as new

Download example source code: bytescoutpdf_add_outlines_to_existing_pdf.zip (14 KB)

Imports Bytescout.PDF
Imports System.Diagnostics

Module Module1

Sub Main()
‘ Create main PDF Doc Engine
Dim engine As New PDFDocEngine(“demo”, “demo”)

‘ Add new document
Dim document As Document = engine.AddDocument(“HelloWorld.pdf”)

‘ Add root outline
Dim outline As Outline = document.Outlines.AddChild()
outline.Title = “Root”

‘ Add link to page 1
Dim child As Outline = outline.AddChild()
child.Title = “Page 1”
child.destination = New Destination(document, “Page1”, False)

‘ Add link to page 2
child = outline.AddChild()
child.Title = “Page 2”
child.destination = New Destination(document, “Page2”, False)

‘ Add NamedDestination to document
document.AddNamedDestination(“Page1”, Destination.FitPage(0))
document.AddNamedDestination(“Page2”, Destination.FitWidth(0, 400))

‘ Save document
document.Save(“OutlinesWereAdded.pdf”)

‘open generated PDF file in default PDF viewer application in Windows
Process.Start(“OutlinesWereAdded.pdf”)
End Sub

End Module

Download example source code: bytescoutpdf_add_outlines_to_existing_pdf.zip (14 KB)

prev
next