GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetActionType Method
A unique action identifier specifying a required action object. This identifier is the only one you need to exactly determine the required action. No other action object needs to be used.

All available methods for obtaining this identifier are listed in the See Also section below.

Example





In This Topic
GetActionType Method (GdPicturePDF)
In This Topic
Returns the action type of a specified PDF action object in the currently loaded PDF document. A PDF action object defines the characteristics and behavior of an action. Actions can be assigned to links, bookmarks, pages, media clips, and form fields in the PDF document. Please see the PdfActionType enumeration for more details about all supported PDF actions.
Syntax
'Declaration
 
Public Function GetActionType( _
   ByVal ActionID As Integer _
) As PdfActionType
public PdfActionType GetActionType( 
   int ActionID
)
public function GetActionType( 
    ActionID: Integer
): PdfActionType; 
public function GetActionType( 
   ActionID : int
) : PdfActionType;
public: PdfActionType GetActionType( 
   int ActionID
) 
public:
PdfActionType GetActionType( 
   int ActionID
) 

Parameters

ActionID
A unique action identifier specifying a required action object. This identifier is the only one you need to exactly determine the required action. No other action object needs to be used.

All available methods for obtaining this identifier are listed in the See Also section below.

Return Value

A member of the PdfActionType enumeration. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Example
The first example shows you how to find out the current action types of all actions associated with all links stored in the PDF document. The second example shows you the same but for the form fields.
Dim caption As String = "Example: GetActionType"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
    Dim pagesCount As Integer = gdpicturePDF.GetPageCount()
    If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (pagesCount > 0) Then
        Dim linksActionTypes As String = ""
        For i As Integer = 1 To pagesCount
            linksActionTypes = linksActionTypes + "Page Nr." + i.ToString()
            status = gdpicturePDF.SelectPage(i)
            If status = GdPictureStatus.OK Then
                Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    If linksCount = 0 Then
                        linksActionTypes = linksActionTypes + " has no links." + vbCrLf
                    Else
                        linksActionTypes = linksActionTypes + " has " + linksCount.ToString() + " links." + vbCrLf
                        Dim err As Boolean = True
                        For x As Integer = 0 To linksCount - 1
                            err = True
                            linksActionTypes = linksActionTypes + "    Link Nr." + x.ToString()
                            Dim linkId As Integer = gdpicturePDF.GetPageLinkAnnotationIdx(x)
                            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                Dim actionId As Integer = gdpicturePDF.GetAnnotationActionID(linkId)
                                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                    Dim actionType As PdfActionType = gdpicturePDF.GetActionType(actionId)
                                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                                        linksActionTypes = linksActionTypes + " is associated with this action: " + actionType.ToString() + vbCrLf
                                        err = False
                                    End If
                                Else
                                    If gdpicturePDF.GetStat() = GdPictureStatus.PropertyNotFound Then
                                        linksActionTypes = linksActionTypes + " has no associated action." + vbCrLf
                                        err = False
                                    End If
                                End If
                            End If
                            If err Then
                                linksActionTypes = linksActionTypes + " has failed to find an action." + vbCrLf
                            End If
                        Next
                    End If
                Else
                    linksActionTypes = linksActionTypes + " has failed to find links." + vbCrLf
                End If
            Else
                linksActionTypes = linksActionTypes + " has failed to select." + vbCrLf
            End If
        Next
        MessageBox.Show(linksActionTypes, caption)
    Else
        MessageBox.Show("The file has failed to load pages.", caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
    int pagesCount = gdpicturePDF.GetPageCount();
    if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && (pagesCount > 0))
    {
        string linksActionTypes = "";
        for (int i = 1; i <= pagesCount; i++)
        {
            linksActionTypes = linksActionTypes + "Page Nr." + i.ToString();
            status = gdpicturePDF.SelectPage(i);
            if (status == GdPictureStatus.OK)
            {
                int linksCount = gdpicturePDF.GetPageLinksCount();
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    if (linksCount == 0)
                        linksActionTypes = linksActionTypes + " has no links.\n";
                    else
                    {
                        linksActionTypes = linksActionTypes + " has " + linksCount.ToString() + " links.\n";
                        bool err = true;
                        for (int x = 0; x <= linksCount - 1; x++)
                        {
                            err = true;
                            linksActionTypes = linksActionTypes + "    Link Nr." + x.ToString();
                            int linkId = gdpicturePDF.GetPageLinkAnnotationIdx(x);
                            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                            {
                                int actionId = gdpicturePDF.GetAnnotationActionID(linkId);
                                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                {
                                    PdfActionType actionType = gdpicturePDF.GetActionType(actionId);
                                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                                    {
                                        linksActionTypes = linksActionTypes + " is associated with this action: " + actionType.ToString() + "\n";
                                        err = false;
                                    }
                                }
                                else
                                {
                                    if (gdpicturePDF.GetStat() == GdPictureStatus.PropertyNotFound)
                                    {
                                        linksActionTypes = linksActionTypes + " has no associated action.\n";
                                        err = false;
                                    }
                                }
                            }
                            if (err)
                                linksActionTypes = linksActionTypes + " has failed to find an action.\n";
                        }
                    }
                }
                else
                {
                    linksActionTypes = linksActionTypes + " has failed to find links.\n";
                }
            }
            else
            {
                linksActionTypes = linksActionTypes + " has failed to select.\n";
            }
        }
        MessageBox.Show(linksActionTypes, caption);
    }
    else
    {
        MessageBox.Show("The file has failed to load pages.", caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Dim caption As String = "Example: GetActionType"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
    Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
        MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
    Else
        Dim FormsActionTypes As String = ""
        For x As Integer = 0 To FormsCount - 1
            FormsActionTypes = FormsActionTypes + "Form Field Nr." + (x + 1).ToString()
            Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
            status = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                Dim FFType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(FFId)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    FormsActionTypes = FormsActionTypes + " is " + FFType.ToString()
                    Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
                        status = gdpicturePDF.GetStat()
                        If status = GdPictureStatus.OK Then
                            FormsActionTypes = FormsActionTypes + " and has associated action: " + ActionType.ToString() + vbCrLf
                        Else
                            FormsActionTypes = FormsActionTypes + ",but the GetActionType() method has failed with the status: " + status.ToString() + vbCrLf
                        End If
                    Else
                        If status = GdPictureStatus.PropertyNotFound Then
                            FormsActionTypes = FormsActionTypes + " and has no associated action." + vbCrLf
                        Else
                            FormsActionTypes = FormsActionTypes + ",but the GetFormFieldActionID() method has failed with the status: " + status.ToString() + vbCrLf
                        End If
                    End If
                Else
                    FormsActionTypes = FormsActionTypes + ": The GetFormFieldType() method has failed with the status: " + status.ToString() + vbCrLf
                End If
            Else
                FormsActionTypes = FormsActionTypes + ": The GetFormFieldId() method has failed with the status: " + status.ToString() + vbCrLf
            End If
        Next
        MessageBox.Show(FormsActionTypes, caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
    int FormsCount = gdpicturePDF.GetFormFieldsCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status != GdPictureStatus.OK || FormsCount == 0)
    {
        MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
    }
    else
    {
        string FormsActionTypes = "";
        for (int x = 0; x <= FormsCount - 1; x++)
        {
            FormsActionTypes = FormsActionTypes + "Form Field Nr." + (x + 1).ToString();
            int FFId = gdpicturePDF.GetFormFieldId(x);
            status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
            {
                PdfFormFieldType FFType = gdpicturePDF.GetFormFieldType(FFId);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    FormsActionTypes = FormsActionTypes + " is " + FFType.ToString();
                    int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                    {
                        PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
                        status = gdpicturePDF.GetStat();
                        if (status == GdPictureStatus.OK)
                        {
                            FormsActionTypes = FormsActionTypes + " and has associated action: " + ActionType.ToString() + "\n";
                        }
                        else
                        {
                            FormsActionTypes = FormsActionTypes + ",but the GetActionType() method has failed with the status: " + status.ToString() + "\n";
                        }
                    }
                    else
                    {
                        if (status == GdPictureStatus.PropertyNotFound)
                        {
                            FormsActionTypes = FormsActionTypes + " and has no associated action.\n";
                        }
                        else
                        {
                            FormsActionTypes = FormsActionTypes + ",but the GetFormFieldActionID() method has failed with the status: " + status.ToString() + "\n";
                        }
                    }
                }
                else
                {
                    FormsActionTypes = FormsActionTypes + ": The GetFormFieldType() method has failed with the status: " + status.ToString() + "\n";
                }
            }
            else
            {
                FormsActionTypes = FormsActionTypes + ": The GetFormFieldId() method has failed with the status: " + status.ToString() + "\n";
            }
        }
        MessageBox.Show(FormsActionTypes, caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also