Action Property (PdfBookmark)
Gets or sets an action to be performed when this bookmark is activated.
Not permitted if a Destination property is set.
Here is an example that shows how to change an action, which have to be performed when PDF bookmark becomes active:
''' <summary>
''' Changes action of the first bookmark of PDF document.
''' </summary>
''' <param name="pdfFilename">The filename of PDF document.</param>
Public Shared Sub ChangeFirstBookmarkAction(pdfFilename As String)
' open PDF document
Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
' create goto action to the last page of PDF document
Dim dest As New Vintasoft.Imaging.Pdf.Tree.PdfDestinationFit(document, document.Pages(document.Pages.Count - 1))
Dim newAction As New Vintasoft.Imaging.Pdf.Tree.PdfGotoAction(dest)
' get the first bookmark of PDF document
Dim bookmark As Vintasoft.Imaging.Pdf.Tree.PdfBookmark = document.Bookmarks(0)
' change the action of bookmark
bookmark.Action = newAction
' save changes to a file
document.SaveChanges()
End Using
End Sub
/// <summary>
/// Changes action of the first bookmark of PDF document.
/// </summary>
/// <param name="pdfFilename">The filename of PDF document.</param>
public static void ChangeFirstBookmarkAction(string pdfFilename)
{
// open PDF document
using (Vintasoft.Imaging.Pdf.PdfDocument document =
new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
{
// create goto action to the last page of PDF document
Vintasoft.Imaging.Pdf.Tree.PdfDestinationFit dest =
new Vintasoft.Imaging.Pdf.Tree.PdfDestinationFit(document, document.Pages[document.Pages.Count - 1]);
Vintasoft.Imaging.Pdf.Tree.PdfGotoAction newAction =
new Vintasoft.Imaging.Pdf.Tree.PdfGotoAction(dest);
// get the first bookmark of PDF document
Vintasoft.Imaging.Pdf.Tree.PdfBookmark bookmark = document.Bookmarks[0];
// change the action of bookmark
bookmark.Action = newAction;
// 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