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)
|