.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfBookmark.Children Property

Gets or sets the collection of bookmark children for a document with a tree-structured hierarchy.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v21.1.Core.dll

Declaration

public IList<PdfBookmark> Children { get; set; }

Property Value

Type Description
IList<PdfBookmark>

A list of PdfBookmark objects that are the collection of bookmark child nodes.

Remarks

A list of bookmark children can’t be null. If you set the Children property to null, the argument null exception occurs.

An instance of the PdfBookmark class is accessible via the PdfDocument.Bookmarks property.

Important

The bookmark hierarchy must contain only distinct instances of the PdfBookmark class. The following code snippet shows this prohibited action.

PdfBookmark bookmark = new PdfBookmark();
bookmark.Children.Add(bookmark);

You can create bookmarks hierarchy using, for example, the following code.

using DevExpress.Pdf;

namespace DocumentCreationAPI {
    class Program {

        static void Main(string[] args) {
            #region #DocumentCreation
            using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
                // Create an empty document using PDF creation options.
                processor.CreateEmptyDocument("..\\..\\Result.pdf", new PdfCreationOptions() {
                    Compatibility = PdfCompatibility.PdfA2b,
                    DisableEmbeddingAllFonts = false
                });
                // Add a page to the PDF.
                processor.AddNewPage(PdfPaperSize.Letter);
                AddBookmarks(processor);
                // Save the document with bookmarks.
                processor.SaveDocument("..\\..\\Result.pdf");

            }
            #endregion #DocumentCreation
        }

        static void AddBookmarks(PdfDocumentProcessor processor) {
            PdfBookmark bookmark1 = new PdfBookmark() { Title = "1" };
            PdfBookmark bookmark2 = new PdfBookmark() { Title = "1.1" };
            PdfBookmark bookmark3 = new PdfBookmark() { Title = "1.1.1" };
            bookmark1.Children.Add(bookmark2);
            bookmark2.Children.Add(bookmark3);
            processor.Document.Bookmarks.Add(bookmark1);
        }
    }
}
See Also