Documents for PDF .NET Edition
Features / Outline
In This Topic
    Outline
    In This Topic

    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 1.7 (Section 12.3.3).

    GcPdf 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.

    PDF Outline

    Add Outline Node

    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)));
    
    Back to Top

    Get Outline Node

    To get a specific outline node from the PDF document:

    1. Create an object of OutlineNodeCollection class.
    2. Use the OutlineNodeCollection object to access a particular outline node using the node index.
      C#
      Copy Code
      // Get the OutlineNodeCollection
      OutlineNodeCollection nodecol = doc.Outlines;
      Console.WriteLine("Outline Title: {0}", nodecol[0].Title);
      
    Back to Top

    Modify Outline Node

    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";
    
    Back to Top

    Delete Outline Node

    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);
    
    Back to Top

    For more information about implementation of outlines using GcPdf, see GcPdf sample browser.