VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Tree Namespace / PdfBookmark Class / Action Property
Example



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
    This example 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: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also