GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetActionURI Method
A unique action identifier specifying a required action object. You can obtain this identifier using these methods: GetViewerOpenActionID, GetBookmarkActionID, GetFormFieldActionID, GetAnnotationActionID or NewActionURI.

Please ensure that the type of the action object specified by this identifier is exactly the PdfActionType.ActionTypeURI. You can check the type of the required action object using the GetActionType method as it is shown in the example below.

Example





In This Topic
GetActionURI Method (GdPicturePDF)
In This Topic
Returns the target (destination) of the specified URI action. A URI action causes a URI to be resolved. A uniform resource identifier (URI) is a string that identifies (resolves to) a resource on the Internet - typically a file that is the destination of a hypertext link. URIs are described in RFC 2396 - Uniform Resource Identifier (URI).
Syntax
'Declaration
 
Public Function GetActionURI( _
   ByVal ActionID As Integer _
) As String
public string GetActionURI( 
   int ActionID
)
public function GetActionURI( 
    ActionID: Integer
): String; 
public function GetActionURI( 
   ActionID : int
) : String;
public: string* GetActionURI( 
   int ActionID
) 
public:
String^ GetActionURI( 
   int ActionID
) 

Parameters

ActionID
A unique action identifier specifying a required action object. You can obtain this identifier using these methods: GetViewerOpenActionID, GetBookmarkActionID, GetFormFieldActionID, GetAnnotationActionID or NewActionURI.

Please ensure that the type of the action object specified by this identifier is exactly the PdfActionType.ActionTypeURI. You can check the type of the required action object using the GetActionType method as it is shown in the example below.

Return Value

A uniform resource identifier as a string. The 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 GetStat method to identify the specific reason for the method's failure, if any. For example, if the action object specified by the action identifier is not of the type PdfActionType.ActionTypeURI, the reason for the method's failure is GdPictureStatus.InvalidParameter.

Example
How to find out the target URI of a URI action associated with the form field in the PDF document.
Dim caption As String = "Example: GetActionURI"
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 ActionsURI As String = ""
        For x As Integer = 0 To FormsCount - 1
            Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                        If ActionType = PdfActionType.ActionTypeURI Then
                            Dim URI As String = gdpicturePDF.GetActionURI(ActionId)
                            status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then
                                ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action with URI = " + URI + vbCrLf
                            Else
                                ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action, but the GetActionURI() method has failed with the status: " + status.ToString() + vbCrLf
                            End If
                        End If
                    End If
                End If
            End If
        Next
        MessageBox.Show(ActionsURI, caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionURI";
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 ActionsURI = "";
        for (int x = 0; x <= FormsCount - 1; x++)
        {
            int FFId = gdpicturePDF.GetFormFieldId(x);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    {
                        if (ActionType == PdfActionType.ActionTypeURI)
                        {
                            string URI = gdpicturePDF.GetActionURI(ActionId);
                            status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK)
                            {
                                ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action with URI = " + URI + "\n";
                            }
                            else
                            {
                                ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action, but the GetActionURI() method has failed with the status: " + status.ToString() + "\n";
                            }
                        }
                    }
                }
            }
        }
        MessageBox.Show(ActionsURI, caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also