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.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
public IList<PdfBookmark> Children { get; set; }
#Property Value
Type | Description |
---|---|
IList<Pdf |
A list of Pdf |
#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 Pdf
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);
}
}
}