Clear() Method (PdfBookmarkCollection)
Removes all items from the collection.
Here is an example that shows how to remove all bookmarks from PDF document:
''' <summary>
''' Removes all bookmarks of PDF document.
''' </summary>
''' <param name="pdfFilename">The filename of PDF document.</param>
Public Shared Sub RemoveAllBookmarks(pdfFilename As String)
' open PDF document
Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
' get the collection of bookmark of PDF document
Dim bookmarks As Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection = document.Bookmarks
' if PDF document has bookmarks
If bookmarks IsNot Nothing Then
' clear bookmarks of PDF document
bookmarks.Clear()
End If
' save changes to a file
document.SaveChanges()
End Using
End Sub
/// <summary>
/// Removes all bookmarks of PDF document.
/// </summary>
/// <param name="pdfFilename">The filename of PDF document.</param>
public static void RemoveAllBookmarks(string pdfFilename)
{
// open PDF document
using (Vintasoft.Imaging.Pdf.PdfDocument document =
new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
{
// get the collection of bookmark of PDF document
Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection bookmarks = document.Bookmarks;
// if PDF document has bookmarks
if (bookmarks != null)
// clear bookmarks of PDF document
bookmarks.Clear();
// save changes to a file
document.SaveChanges();
}
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5