GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / NewActionURI Method
The uniform resource identifier to resolve, encoded in 7-bit ASCII. For example "http://www.gdpicture.com".
A flag specifying whether to track the mouse position when the URI is resolved. The default value is false.

This entry only applies to actions triggered by the user's clicking an annotation; it is ignored for actions associated with bookmarks or with a document's OpenAction entry.

Example





In This Topic
NewActionURI Method (GdPicturePDF)
In This Topic
Creates a new action of the type URI. 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 NewActionURI( _
   ByVal URI As String, _
   ByVal IsMap As Boolean _
) As Integer
public int NewActionURI( 
   string URI,
   bool IsMap
)
public function NewActionURI( 
    URI: String;
    IsMap: Boolean
): Integer; 
public function NewActionURI( 
   URI : String,
   IsMap : boolean
) : int;
public: int NewActionURI( 
   string* URI,
   bool IsMap
) 
public:
int NewActionURI( 
   String^ URI,
   bool IsMap
) 

Parameters

URI
The uniform resource identifier to resolve, encoded in 7-bit ASCII. For example "http://www.gdpicture.com".
IsMap
A flag specifying whether to track the mouse position when the URI is resolved. The default value is false.

This entry only applies to actions triggered by the user's clicking an annotation; it is ignored for actions associated with bookmarks or with a document's OpenAction entry.

Return Value

The unique action identifier of the newly created action of the type URI. The GetStat method can be subsequently used to determine if this method has been successful.

You can subsequently apply this identifier when creating actions using these methods: SetViewerOpenAction, SetBookmarkAction, SetAnnotationAction or SetFormFieldAction.

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.

Also be careful about the PDF/A conformance of the current PDF document. External content references (hypertext links) are forbidden in the PDF/A compliant documents.

Example
How to create a form field of the type button with the associated URI action. Clicking this button in the created PDF document results in the opening of the specified link in the internet explorer.
Dim gdpicturePDF As New GdPicturePDF()
Dim failedMethod As String = "NewPDF()"
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    failedMethod = "NewPage() or SelectPage()"
    If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
        failedMethod = "AddStandardFont()"
        Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier)
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            failedMethod = "AddPushButtonFormField()"
            Dim fieldID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Open http://www.gdpicture.com", fontResName, 6, 255, 0, 0)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                failedMethod = "NewActionURI()"
                Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
                If (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
                    failedMethod = "SetFormFieldAction() or SaveToFile()"
                    If (gdpicturePDF.SetFormFieldAction(fieldID, actionID) = GdPictureStatus.OK) AndAlso (gdpicturePDF.SaveToFile("button_action.pdf") = GdPictureStatus.OK) Then
                        failedMethod = ""
                        MessageBox.Show("The PDF document containing the button associated with the URI action has been saved successfully.", "Example: NewActionURI")
                    End If
                End If
            End If
        End If
    End If
End If
If failedMethod <> "" Then
    MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionURI")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string failedMethod = "NewPDF()";
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    failedMethod = "NewPage() or SelectPage()";
    if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
        (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
    {
        failedMethod = "AddStandardFont()";
        string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier);
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            failedMethod = "AddPushButtonFormField()";
            int fieldID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Open http://www.gdpicture.com", fontResName, 6, 255, 0, 0);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                failedMethod = "NewActionURI()";
                int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    failedMethod = "SetFormFieldAction() or SaveToFile()";
                    if ((gdpicturePDF.SetFormFieldAction(fieldID, actionID) == GdPictureStatus.OK) &&
                        (gdpicturePDF.SaveToFile("button_action.pdf") == GdPictureStatus.OK))
                    {
                        failedMethod = "";
                        MessageBox.Show("The PDF document containing the button associated with the URI action has been saved successfully.", "Example: NewActionURI");
                    }
                 }
            }
        }
    }
}
if (failedMethod != "")
    MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionURI");
gdpicturePDF.Dispose();
This example show you how to create a URI action associated with a bookmark.
Dim caption As String = "Example: NewActionURI"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
   (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) Then
    Dim rootBookmark As Integer = gdpicturePDF.NewBookmark(0, "Links Navigation")
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim bookMarkID1 As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Visit GdPicture website!")
        status = gdpicturePDF.GetStat()
        Dim bookMarkID2 As Integer = 0
        If status = GdPictureStatus.OK Then
            bookMarkID2 = gdpicturePDF.NewBookmark(rootBookmark, "Read GdPicture.NET documentation online!")
            status = gdpicturePDF.GetStat()
        End If
        If status = GdPictureStatus.OK Then
            Dim actionID1 As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
            status = gdpicturePDF.GetStat()
            If status <> GdPictureStatus.OK Then
                MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption)
            End If
            Dim actionID2 As Integer = -1
            If status = GdPictureStatus.OK Then
                actionID2 = gdpicturePDF.NewActionURI("http://www.guides.gdpicture.com", False)
                status = gdpicturePDF.GetStat()
                If status <> GdPictureStatus.OK Then
                    MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption)
                End If
            End If
            If status = GdPictureStatus.OK Then
                status = gdpicturePDF.SetBookmarkAction(bookMarkID1, actionID1)
                If status = GdPictureStatus.OK Then
                    status = gdpicturePDF.SetBookmarkAction(bookMarkID2, actionID2)
                    If status = GdPictureStatus.OK Then
                        status = gdpicturePDF.SaveToFile("actions_NewActionURI.pdf")
                        If status = GdPictureStatus.OK Then
                            MessageBox.Show("The new file has been saved successfully.", caption)
                        Else
                            MessageBox.Show("The new file can't be saved. Status: " + status.ToString(), caption)
                        End If
                    End If
                End If
            End If
        End If
    End If
    If status <> GdPictureStatus.OK Then
        MessageBox.Show("The example has NOT been followed successfully.", caption)
    End If
Else
    MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionURI";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
    (gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK))
{
    int rootBookmark = gdpicturePDF.NewBookmark(0, "Links Navigation");
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        int bookMarkID1 = gdpicturePDF.NewBookmark(rootBookmark, "Visit GdPicture website!");
        status = gdpicturePDF.GetStat();
        int bookMarkID2 = 0;
        if (status == GdPictureStatus.OK)
        {
            bookMarkID2 = gdpicturePDF.NewBookmark(rootBookmark, "Read GdPicture.NET documentation online!");
            status = gdpicturePDF.GetStat();
        }
        if (status == GdPictureStatus.OK)
        {
            int actionID1 = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
            status = gdpicturePDF.GetStat();
            if (status != GdPictureStatus.OK)
                MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption);
            int actionID2 = -1;
            if (status == GdPictureStatus.OK)
            {
                actionID2 = gdpicturePDF.NewActionURI("http://www.guides.gdpicture.com", false);
                status = gdpicturePDF.GetStat();
                if (status != GdPictureStatus.OK)
                    MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption);
            }
            if (status == GdPictureStatus.OK)
            {
                status = gdpicturePDF.SetBookmarkAction(bookMarkID1, actionID1);
                if (status == GdPictureStatus.OK)
                {
                    status = gdpicturePDF.SetBookmarkAction(bookMarkID2, actionID2);
                    if (status == GdPictureStatus.OK)
                    {
                        status = gdpicturePDF.SaveToFile("actions_NewActionURI.pdf");
                        if (status == GdPictureStatus.OK)
                            MessageBox.Show("The new file has been saved successfully.", caption);
                        else
                            MessageBox.Show("The new file can't be saved. Status: " + status.ToString(), caption);
                    }
                }
            }
        }
    }
    if (status != GdPictureStatus.OK)
        MessageBox.Show("The example has NOT been followed successfully.", caption);
}
else
{
    MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
gdpicturePDF.Dispose();
See Also