VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfBookmark Class / Action Property
Syntax Remarks Example Requirements SeeAlso
In This Topic
    Action Property (PdfBookmark)
    In This Topic
    Gets or sets an action to be performed when this bookmark is activated.
    Syntax
    'Declaration
    
    Public Property Action As PdfAction
    
    
    public PdfAction Action { get; set; }
    
    
    public: __property PdfAction* get_Action();
    public: __property void set_Action(
    PdfAction* value
    );
    public:
    property PdfAction^ Action { PdfAction^ get(); void set(PdfAction^ value); }
    Remarks

    Not permitted if a Destination property is set.

    Example

    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();
        }
    }
    
    

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also