A unique bookmark identifier specifying a required bookmark object.

You can obtain this identifier using these methods: GdPicturePDF.NewBookmark, GdPicturePDF.GetBookmarkRootID, GdPicturePDF.GetBookmarkFirstChildID, GdPicturePDF.GetBookmarkNextID, GdPicturePDF.GetBookmarkPrevID or GdPicturePDF.GetBookmarkParentID.

A unique action identifier specifying a required action object.

You can obtain this identifier when creating an action, for example, using the GdPicturePDF.NewActionGoTo, GdPicturePDF.NewActionGoToR, GdPicturePDF.NewActionLaunch, GdPicturePDF.NewActionJavaScript, GdPicturePDF.NewActionNamed or GdPicturePDF.NewActionURI methods.

Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / SetBookmarkAction Method

SetBookmarkAction Method (GdPicturePDF)

In This Topic
Associates a specified action (identified with a unique action identifier) with a specified bookmark item (identified with a unique bookmark identifier).
Syntax
'Declaration

 

Public Function SetBookmarkAction( _

   ByVal BookmarkID As Integer, _

   ByVal ActionID As Integer _

) As GdPictureStatus
public GdPictureStatus SetBookmarkAction( 

   int BookmarkID,

   int ActionID

)
public function SetBookmarkAction( 

    BookmarkID: Integer;

    ActionID: Integer

): GdPictureStatus; 
public function SetBookmarkAction( 

   BookmarkID : int,

   ActionID : int

) : GdPictureStatus;
public: GdPictureStatus SetBookmarkAction( 

   int BookmarkID,

   int ActionID

) 
public:

GdPictureStatus SetBookmarkAction( 

   int BookmarkID,

   int ActionID

) 

Parameters

BookmarkID
A unique bookmark identifier specifying a required bookmark object.

You can obtain this identifier using these methods: GdPicturePDF.NewBookmark, GdPicturePDF.GetBookmarkRootID, GdPicturePDF.GetBookmarkFirstChildID, GdPicturePDF.GetBookmarkNextID, GdPicturePDF.GetBookmarkPrevID or GdPicturePDF.GetBookmarkParentID.

ActionID
A unique action identifier specifying a required action object.

You can obtain this identifier when creating an action, for example, using the GdPicturePDF.NewActionGoTo, GdPicturePDF.NewActionGoToR, GdPicturePDF.NewActionLaunch, GdPicturePDF.NewActionJavaScript, GdPicturePDF.NewActionNamed or GdPicturePDF.NewActionURI methods.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to assign an action to a bookmark item. This example creates a bookmark hierarchy with 10 bookmark items, each bookmark points to one page in the PDF document.
Dim caption As String = "Example: SetBookmarkAction"

Dim gdpicturePDF As New GdPicturePDF()

If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then

    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)

    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)

    Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)

    Dim status As GdPictureStatus = gdpicturePDF.GetStat()

    If status = GdPictureStatus.OK Then

        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)

    Else

        Dim rootBookmark As Integer = gdpicturePDF.NewBookmark(0, "Pages Navigation")

        status = gdpicturePDF.GetStat()

        If status <> GdPictureStatus.OK Then

            MessageBox.Show("The NewBookmark() method (root bookmark) has failed with the status: " + status.ToString(), caption)

        Else

            Dim failure As Boolean = True

            Dim i As Integer = 0

            Do

                i += 1

                If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso

                   (gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) = GdPictureStatus.OK) Then

                    Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1)

                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

                        Dim bookMarkID As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString())

                        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

                            failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) <> GdPictureStatus.OK)

                        End If

                    End If

                End If

                If failure Then

                    MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption)

                End If

            Loop While Not failure AndAlso i < 10

            

            If Not failure AndAlso (gdpicturePDF.SaveToFile("bookmarks_Actions.pdf") = GdPictureStatus.OK) Then

                MessageBox.Show("The new file has been saved successfully.", caption)

            Else

                MessageBox.Show("The new file can't be saved.", caption)

            End If

        End If

    End If

Else

    MessageBox.Show("The new file can't be created.", caption)

End If

gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkAction";

GdPicturePDF gdpicturePDF = new GdPicturePDF();

if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)

{

    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);

    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);

    string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);

    if (gdpicturePDF.GetStat() != GdPictureStatus.OK)

        MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

    else

    {

        int rootBookmark = gdpicturePDF.NewBookmark(0, "Pages Navigation");

        GdPictureStatus status = gdpicturePDF.GetStat();

        if (status != GdPictureStatus.OK)

            MessageBox.Show("The NewBookmark() method (root bookmark) has failed with the status: " + status.ToString(), caption);

        else

        {

            bool failure = true;

            int i = 0;

            do

            {

                i++;

                if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&

                    (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&

                    (gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&

                    (gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) == GdPictureStatus.OK))

                {

                    int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1);

                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

                    {

                        int bookMarkID = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString());

                        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

                        {

                            failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) != GdPictureStatus.OK);

                        }

                    }

                }

                if (failure)

                    MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption);

            } while (!failure && i < 10);

            

            if (!failure && (gdpicturePDF.SaveToFile("bookmarks_Actions.pdf") == GdPictureStatus.OK))

                MessageBox.Show("The new file has been saved successfully.", caption);

            else

                MessageBox.Show("The new file can't be saved.", caption);

        }

    }

}

else

{

    MessageBox.Show("The new file can't be created.", caption);

}

gdpicturePDF.Dispose();
See Also