BookmarksOutlineLevelCollection.Add

BookmarksOutlineLevelCollection Add method. Adds a bookmark to the collection.

BookmarksOutlineLevelCollection.Add method

Adds a bookmark to the collection.

public void Add(string name, int outlineLevel)
ParameterTypeDescription
nameStringThe case-insensitive name of the bookmark to add.
outlineLevelInt32The outline level of the bookmark. Valid range is 0 to 9.

Examples

Shows how to configure bookmarks outline levels.

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
// Configure exporting bookmarks in document header/footer
pdfSaveOptions.HeaderFooterBookmarksExportMode = HeaderFooterBookmarksExportMode.None;
// Set default bookmarks outline level
pdfSaveOptions.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
// Specify concrete bookmark outline level.
pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("bk3", 2);
pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Add("bk4", 3);
// Remove bookmark
if (pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Contains("bk3"))
    pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Remove("bk3");
// Clear all specified bookmark outline levels.
if (pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Count > 0)
    pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels.Clear();
// Add bookmark back
pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels["bk3"] = 2;
Converter.Create()
    .From(MyDir + "Simple.docx")
    .To(ArtifactsDir + "BookmarksOutlineLevel.pdf", pdfSaveOptions)
    .Execute();

See Also