Outline is a hierarchical list of items used to organize and display the document structure to the user so that the user can interactively navigate to a particular topic or a location in a document. For more information on outline, see PDF specification 2.0 (Section 12.3.3).
DsPdf allows you to define an outline node in a PDF document using OutlineNode class. You can also add child nodes to the outline nodes and choose whether to display the expanded list with visible child nodes or a compact list using Expanded property of the OutlineNode class. This class also provides methods and properties to manipulate document's outline.
To add an outline node in the PDF document, pass the instance of OutlineNode class as a parameter to the Add method.
C# |
Copy Code
|
---|---|
// Add outline node using Add method doc.Outlines.Add(new OutlineNode("Chapter 5", new DestinationFitH(8, null))); |
To get a specific outline node from the PDF document:
C# |
Copy Code
|
---|---|
// Get the OutlineNodeCollection OutlineNodeCollection nodecol = doc.Outlines; Console.WriteLine("Outline Title: {0}", nodecol[0].Title); |
To modify a specific outline node in a PDF file, get the outline from OutlineNodeCollection by specifying its index and set the new value to its properties such as Title property.
C# |
Copy Code
|
---|---|
// Modify an outline node nodecol[6].Title = "Testing Chapter"; |
To delete all the outline nodes from a PDF document, use Clear method. Apart from this, RemoveAt method can be used to delete a particular outline by specifying its index value.
C# |
Copy Code
|
---|---|
// Delete all the outline nodes doc.Outlines.Clear(); // Delete a particular outline node doc.Outlines.RemoveAt(1); |
For more information about implementation of outlines using DsPdf, see DsPdf sample browser.