GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetViewerOpenActionID Method
Example





In This Topic
GetViewerOpenActionID Method (GdPicturePDF)
In This Topic
Gets the unique action identifier of the action defined in the OpenAction entry in the PDF document's catalog. If this action is set, it defines a destination to be displayed or an action to be carried out when the document is opened. If it is absent, the document should be opened to the top of the first page at the default magnification factor.
Syntax
'Declaration
 
Public Function GetViewerOpenActionID() As Integer
public int GetViewerOpenActionID()
public function GetViewerOpenActionID(): Integer; 
public function GetViewerOpenActionID() : int;
public: int GetViewerOpenActionID(); 
public:
int GetViewerOpenActionID(); 

Return Value

A unique action identifier of the action known as OpenAction. The GetStat method can be subsequently used to determine if this method has been successful.

You can use the GetActionType method to determine the type of this action as it is shown in the example below.

Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any. For example, if the OpenAction entry is not available in the PDF document's catalog, the reason for the method's failure is GdPictureStatus.PropertyNotFound.

Example
How to find out if the OpenAction action is defined in the PDF document. If this action is specified, the example also shows you how to determine the type of this action.
Dim caption As String = "Example: GetViewerOpenActionID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("actions.pdf", False)
If status = GdPictureStatus.OK Then
    Dim actionID As Integer = gdpicturePDF.GetViewerOpenActionID()
    status = gdpicturePDF.GetStat()
    Select Case status
        Case GdPictureStatus.OK
            Dim actionType As PdfActionType = gdpicturePDF.GetActionType(actionID)
            Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
            If status1 = GdPictureStatus.OK Then
                MessageBox.Show("The OpenAction action of the type " + actionType.ToString() + " is defined for this document.", caption)
            Else
                MessageBox.Show("The OpenAction action is defined for this document, but the GetActionType() method has failed with the status: " + status1.ToString(), caption)
            End If
            Exit Select
        Case GdPictureStatus.PropertyNotFound
            MessageBox.Show("The OpenAction action is not defined for this document.", caption)
            Exit Select
        Case Else
            MessageBox.Show("The GetViewerOpenActionID() method has failed with the status: " + status.ToString(), caption)
            Exit Select
    End Select
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetViewerOpenActionID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("actions.pdf", false);
if (status == GdPictureStatus.OK)
{
    int actionID = gdpicturePDF.GetViewerOpenActionID();
    status = gdpicturePDF.GetStat();
    switch (status)
    {
        case GdPictureStatus.OK:
            PdfActionType actionType = gdpicturePDF.GetActionType(actionID);
            GdPictureStatus status1 = gdpicturePDF.GetStat();
            if (status1 == GdPictureStatus.OK)
                MessageBox.Show("The OpenAction action of the type " + actionType.ToString() + " is defined for this document.", caption);
            else
                MessageBox.Show("The OpenAction action is defined for this document, but the GetActionType() method has failed with the status: " + status1.ToString(), caption);
            break;
        case GdPictureStatus.PropertyNotFound:
            MessageBox.Show("The OpenAction action is not defined for this document.", caption);
            break;
        default:
            MessageBox.Show("The GetViewerOpenActionID() method has failed with the status: " + status.ToString(), caption);
            break;
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also