Create table of contents in PDF documents 4

With the release of XFINIUM.PDF 6.2 the table of contents can be generated automatically for flow PDF documents.

The table of contents is generated with the help of a new flow content class: PdfFlowHeadingContent. Heading content is similar to text content but it allows to create a hierarchy based on its Level property. 8 levels (1 to 8) of heading content are supported.
The heading level is used to generate the parent-child bookmarks in document outline and to generate the heading numbers, if required.

Adding heading content is done like this:

The table of contents is generated from all the heading objects included in the document. It should be generated at the end after the entire document content has been created.

The PdfFlowContent.GenerateTableOfContents() method generates the table of contents in the document. The method can accept a PdfFlowDocumentTOCSettings object as parameter for customizing the table of contents. The properties of the PdfFlowDocumentTOCSettings object control how the table of contents is generated.

The code above is taken from the TableOfContents sample included in the XFINIUM.PDF install kits.
After running the sample the table of contents is generated like in the screenshot below.

Table of contents

Table of contents

On the left the table of contents as document outline and in the center the page that displays the table of contents. The entries in the table of contents page are clickable links that take the reader to the corresponding section in the document.

4 thoughts on “Create table of contents in PDF documents

  1. Reply Tyler Jul 12,2016 12:03 pm

    Hi, i’m evaluating Xfinium, and I just want to know how to display a pdf? I can’t find any info on how to show a pdf in my app, using xfinium. Can you please point me to a resource that explains how to do that?

    • Reply xfinium.pdf Jul 12,2016 1:13 pm

      PDF viewer controls are under development and they will be available later this year. For the moment a PDF file can be displayed if it is rendered as image and the image is displayed. The PDFToImage sample shows this functionality.

  2. Reply Neil Sep 7,2016 9:07 am

    Do you have an estimated release date for the PDF Viewer controls?

    • Reply xfinium.pdf Sep 7,2016 11:02 am

      Our estimates are end of the year for all of them to be available. WinForms, WPF and UWP will come first, Android and iOS (Xamarin.Forms) will follow.

Leave a Reply