How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

PDF VB.NET Library
How to Edit PDF Bookmark and Outline in VB.NET


Empower Your VB.NET Project with Rapid PDF Internal Navigation Via Bookmark and Outline









As a powerful PDF editing control, RasterEdge XDoc.PDF SDK package provides PDF file navigation features for your VB.NET project. On this tutorial, VB.NET users can learn how to retrieve and update PDF bookmark or outline. Users can get a quick evaluation by using following sample code.





VB.NET Project: DLLs for Bookmark Edit



In order to run the sample code, the following steps would be necessary.




VB.NET: Retrieve PDF Document Outline



Please directly copy and paste VB.NET demo code below to your project to retrieve PDF file outline.




' Retrieve PDF document outline.
Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)
Dim outline As REOutline = doc.GetOutline()
For Each entry As REEntry In outline.Entry
    Console.WriteLine("Page:     {0}", entry.GetPageIndex())
    Console.WriteLine("Level:    {0}", entry.GetLevel())
    Console.WriteLine("Position: {0}", entry.GetLocation())
    Console.WriteLine("Text:     {0}", entry.GetText())
Next





VB.NET: Update PDF Document Outline



Or you can also edit and update PDF document outline as below.




Dim inputFilePath As String = Program.RootPath + "\\" + "2.pdf"
Dim outputFilePath As String = Program.RootPath + "\\" + "Output_Outline.pdf"
Dim doc As PDFDocument = New PDFDocument(inputFilePath)

' Initial a new outline object.
Dim outline As REOutline = New REOutline()

' Create 1st entry: Level = 1; Location: page index 0, y = 50.
Dim entryChapter1 As Outline = New Outline("Chapter 1: *******", 1, 0, 50)

' Add 1st entry to outline.
outline.Entry.Add(entryChapter1)

' Create 1st entry's child entries.
' Create 1st child entry: Level = 2; Location: page index 1, y = 0.
Dim entryChapter11 As Outline = New Outline("###### #### #### #### ###", 2, 1, 0)

' Connect this entry to the parent entry.
entryChapter11.SetParentREEntry(entryChapter1)

' Add 1st child of 1st entry to outline.
outline.Entry.Add(entryChapter11)

' Create 2nd child entry: Level = 2; Location: page index 2, y = 0.
Dim entryChapter12 As OutLine = New OutLine("## ## ## ## ## #### ###", 2, 2, 0)

' Connect this entry to the parent entry.
entryChapter12.SetParentREEntry(entryChapter1)

' Add 2nd child of 1st entry to outline.
outline.Entry.Add(entryChapter12)

' Create 2nd entry: Level = 1; Location: page index 3, y = 100.
Dim entryChapter2 As OutLine = New OutLine("Chapter 2: ******* ****", 1, 3, 100)

' Add 2nd entry to outline.
outline.Entry.Add(entryChapter2)

' Create 3rd entry: Level = 1; Location: page index 5, y = 200.
Dim entryChapter3 As OutLine = New OutLine("Chapter 3: **** **** ***", 1, 5, 200)

' Add 3rd entry to outline.
outline.Entry.Add(entryChapter3)

' Create 3rd entry's child entries.
' Create 1st child entry: Level = 2; Location: page index 9, y = 0.
Dim entryChapter31 As OutLine = New OutLine("# #### ###", 2, 9, 0)

' Connect this entry to the parent entry.
entryChapter31.SetParentREEntry(entryChapter3)

' Add 1st child of 3rd entry to outline.
outline.Entry.Add(entryChapter31)

' Create a child entry for the 1st child entry of the 3rd entry.
' Create entry: Level = 3; Location: page index 9, y = 500.
Dim entryChapter311 As OutLine = New OutLine("???? ???? ??? ???", 3, 9, 500)

' Connect this entry to the parent entry.
entryChapter311.SetParentREEntry(entryChapter31)

' Add 1st child of 3rd entry to outline.
outline.Entry.Add(entryChapter311)

' Create 4th entry: Level = 1; Location: page index 10, y = 0.
Dim entryChapter4 As OutLine = New OutLine("Chapter 4: ******* ** ** **** ***", 1, 10, 0)

' Add 4th entry to outline.
outline.Entry.Add(entryChapter4)

' Create 5th entry: Level = 1; Location: page index 20, y = 0.
Dim entryChapter5 As OutLine = New OutLine("Chapter 5: * ** **** **** ****", 1, 20, 0)

' Add 5th entry to outline.
outline.Entry.Add(entryChapter5)

' Update the new outline.
doc.SetOutline(outline)

doc.Save(outputFilePath)