Class BookmarksOutlineLevelCollection

Class BookmarksOutlineLevelCollection

Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (25.12.0)

A collection of individual bookmarks outline level.

To learn more, visit the Working with Bookmarks documentation article.

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

Inheritance

object BookmarksOutlineLevelCollection

Implements

IEnumerable<KeyValuePair<string, int>> , IEnumerable

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

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.

Constructors

BookmarksOutlineLevelCollection()

public BookmarksOutlineLevelCollection()

Properties

Count

Gets the number of elements contained in the collection.

public int Count { get; }

Property Value

int

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

this[string]

Gets or a sets a bookmark outline level by the bookmark name.

public int this[string name] { get; set; }

Property Value

int

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

this[int]

Gets or sets a bookmark outline level at the specified index.

public int this[int index] { get; set; }

Property Value

int

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

Methods

Add(string, int)

Adds a bookmark to the collection.

public void Add(string name, int outlineLevel)

Parameters

name string

The case-insensitive name of the bookmark to add.

outlineLevel int

The outline level of the bookmark. Valid range is 0 to 9.

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

Clear()

Removes all elements from the collection.

public void Clear()

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

Contains(string)

Determines whether the collection contains a bookmark with the given name.

public bool Contains(string name)

Parameters

name string

Case-insensitive name of the bookmark to locate.

Returns

bool

true if item is found in the collection; otherwise, false.

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

GetEnumerator()

Returns an enumerator object that can be used to iterate over all items in the collection.

public IEnumerator<KeyValuePair<string, int>> GetEnumerator()

Returns

IEnumerator < KeyValuePair < string , int >>

IndexOfKey(string)

Returns the zero-based index of the specified bookmark in the collection.

public int IndexOfKey(string name)

Parameters

name string

The case-insensitive name of the bookmark.

Returns

int

The zero based index. Negative value if not found.

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

Remove(string)

Removes a bookmark with the specified name from the collection.

public void Remove(string name)

Parameters

name string

The case-insensitive name of the bookmark.

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();

RemoveAt(int)

Removes a bookmark at the specified index.

public void RemoveAt(int index)

Parameters

index int

The zero based index.

Examples

Shows how to set outline levels for bookmarks.

Document doc = new Document();
                                                         DocumentBuilder builder = new DocumentBuilder(doc);

                                                         // Insert a bookmark with another bookmark nested inside it.
                                                         builder.StartBookmark("Bookmark 1");
                                                         builder.Writeln("Text inside Bookmark 1.");

                                                         builder.StartBookmark("Bookmark 2");
                                                         builder.Writeln("Text inside Bookmark 1 and 2.");
                                                         builder.EndBookmark("Bookmark 2");

                                                         builder.Writeln("Text inside Bookmark 1.");
                                                         builder.EndBookmark("Bookmark 1");

                                                         // Insert another bookmark.
                                                         builder.StartBookmark("Bookmark 3");
                                                         builder.Writeln("Text inside Bookmark 3.");
                                                         builder.EndBookmark("Bookmark 3");

                                                         // When saving to .pdf, bookmarks can be accessed via a drop-down menu and used as anchors by most readers.
                                                         // Bookmarks can also have numeric values for outline levels,
                                                         // enabling lower level outline entries to hide higher-level child entries when collapsed in the reader.
                                                         PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                         BookmarksOutlineLevelCollection outlineLevels = pdfSaveOptions.OutlineOptions.BookmarksOutlineLevels;

                                                         outlineLevels.Add("Bookmark 1", 1);
                                                         outlineLevels.Add("Bookmark 2", 2);
                                                         outlineLevels.Add("Bookmark 3", 3);

                                                         Assert.That(outlineLevels.Count, Is.EqualTo(3));
                                                         Assert.That(outlineLevels.Contains("Bookmark 1"), Is.True);
                                                         Assert.That(outlineLevels[0], Is.EqualTo(1));
                                                         Assert.That(outlineLevels["Bookmark 2"], Is.EqualTo(2));
                                                         Assert.That(outlineLevels.IndexOfKey("Bookmark 3"), Is.EqualTo(2));

                                                         // We can remove two elements so that only the outline level designation for "Bookmark 1" is left.
                                                         outlineLevels.RemoveAt(2);
                                                         outlineLevels.Remove("Bookmark 2");

                                                         // There are nine outline levels. Their numbering will be optimized during the save operation.
                                                         // In this case, levels "5" and "9" will become "2" and "3".
                                                         outlineLevels.Add("Bookmark 2", 5);
                                                         outlineLevels.Add("Bookmark 3", 9);

                                                         doc.Save(ArtifactsDir + "BookmarksOutlineLevelCollection.BookmarkLevels.pdf", pdfSaveOptions);

                                                         // Emptying this collection will preserve the bookmarks and put them all on the same outline level.
                                                         outlineLevels.Clear();
 English