BookmarksOutlineLevelCollection Class

Wordize.Saving.BookmarksOutlineLevelCollection class. A collection of individual bookmarks outline level.

BookmarksOutlineLevelCollection class

A collection of individual bookmarks outline level.

public class BookmarksOutlineLevelCollection : IEnumerable<KeyValuePair<string, int>>

Properties

NameDescription
Count { get; }Gets the number of elements contained in the collection.
Item { get; set; }Gets or a sets a bookmark outline level by the bookmark name. (2 indexers)

Methods

NameDescription
Add(string, int)Adds a bookmark to the collection.
Clear()Removes all elements from the collection.
Contains(string)Determines whether the collection contains a bookmark with the given name.
GetEnumerator()Returns an enumerator object that can be used to iterate over all items in the collection.
IndexOfKey(string)Returns the zero-based index of the specified bookmark in the collection.
Remove(string)Removes a bookmark with the specified name from the collection.
RemoveAt(int)Removes a bookmark at the specified index.

Remarks

Key is a case-insensitive string bookmark name. Value is a int bookmark outline level.

Bookmark outline level may be a value from 0 to 9. Specify 0 and Word bookmark will not be displayed in the document outline. Specify 1 and Word bookmark will be displayed in the document outline at level 1; 2 for level 2 and so on.

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