Reading Outline Information

When merging or appending PDF documents that contain Outlines, the information within those outlines are retrieved directly from a PdfDocument object. Retrieving these Outline properties from the PdfDocument object is as easy as instantiating a PdfDocument object based on the PDF that you are merging or appending. That PdfDocument then will contain a collection of outlines that you can access directly.

The following example demonstrates how to read text and a page number from an existing collection of outlines in a PdfDocument object. It then displays that information.

PdfDocument pdfDocument = new PdfDocument(pdfFilePath);
for (int i = 0; i < pdfDocument.Outlines.Count; i++)
{
    Console.WriteLine(pdfDocument.Outlines[i].Text + ": " + pdfDocument.Outlines[i].TargetPageNumber);
}
Console.ReadLine();        
Dim MyPdfDocument As New PdfDocument(pdfFilePath) 
For i As Integer = 0 To MyPdfDocument.Outlines.Count - 1 
    Console.WriteLine(MyPdfDocument.Outlines(i).Text + ": " + MyPdfDocument.Outlines(i).TargetPageNumber) 
Next 
Console.ReadLine()

In this topic