GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / NewActionGoToR Method / NewActionGoToR(PdfDestinationType,String,Boolean,Int32,Single,Single,Single,Single,Single) Method
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination to jump specified by the this action.
The relative path of the file in which the destination is located.
Specifies whether to open the destination document in a new window. If the value is set to false, the destination document replaces the current document in the same window.
The destination page number located in the File parameter.
The horizontal (left) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The horizontal (right) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (bottom) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (top) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The zoom factor to use when displaying the destination page according to the DestinationType configuration. Please use the value of 1 to represent the 100% zoom, 2 means 200%, 0,5 means 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
Example





In This Topic
NewActionGoToR(PdfDestinationType,String,Boolean,Int32,Single,Single,Single,Single,Single) Method
In This Topic
Creates a new action of the type GoToR. A go-to remote action jumps to a destination in another PDF file instead of the current file, as it is for an ordinary go-to action. In other words, a GoToR action changes the view to a specified destination (page, location, and magnification factor) in a specified file.
Syntax
'Declaration
 
Public Overloads Function NewActionGoToR( _
   ByVal DestinationType As PdfDestinationType, _
   ByVal FilePath As String, _
   ByVal NewWindow As Boolean, _
   ByVal Page As Integer, _
   ByVal Left As Single, _
   ByVal Right As Single, _
   ByVal Bottom As Single, _
   ByVal Top As Single, _
   ByVal Zoom As Single _
) As Integer
public int NewActionGoToR( 
   PdfDestinationType DestinationType,
   string FilePath,
   bool NewWindow,
   int Page,
   float Left,
   float Right,
   float Bottom,
   float Top,
   float Zoom
)
public function NewActionGoToR( 
    DestinationType: PdfDestinationType;
    FilePath: String;
    NewWindow: Boolean;
    Page: Integer;
    Left: Single;
    Right: Single;
    Bottom: Single;
    Top: Single;
    Zoom: Single
): Integer; 
public function NewActionGoToR( 
   DestinationType : PdfDestinationType,
   FilePath : String,
   NewWindow : boolean,
   Page : int,
   Left : float,
   Right : float,
   Bottom : float,
   Top : float,
   Zoom : float
) : int;
public: int NewActionGoToR( 
   PdfDestinationType DestinationType,
   string* FilePath,
   bool NewWindow,
   int Page,
   float Left,
   float Right,
   float Bottom,
   float Top,
   float Zoom
) 
public:
int NewActionGoToR( 
   PdfDestinationType DestinationType,
   String^ FilePath,
   bool NewWindow,
   int Page,
   float Left,
   float Right,
   float Bottom,
   float Top,
   float Zoom
) 

Parameters

DestinationType
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination to jump specified by the this action.
FilePath
The relative path of the file in which the destination is located.
NewWindow
Specifies whether to open the destination document in a new window. If the value is set to false, the destination document replaces the current document in the same window.
Page
The destination page number located in the File parameter.
Left
The horizontal (left) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Right
The horizontal (right) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Bottom
The vertical (bottom) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Top
The vertical (top) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Zoom
The zoom factor to use when displaying the destination page according to the DestinationType configuration. Please use the value of 1 to represent the 100% zoom, 2 means 200%, 0,5 means 50%, etc. The value of 0 means that the current zoom value should remain unchanged.

Return Value

The unique action identifier of the newly created action of the type GoToR. 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.

All values of the coordinates are expressed in the current units defined by the SetMeasurementUnit method according to the current coordinate space defined by the SetOrigin method.

Example
How to create a link associated with the GoToR action. The example creates two PDF documents which are linked together through the links associated with the GoToR action.
Dim caption As String = "Example: NewActionGoToR"
Dim gdpicturePDF As New GdPicturePDF()
Dim failure As Boolean = True
Dim textSize As Single = 12, textWidth As Single = 0, textHeight As Single = 0
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    'The creation of the first pdf1.pdf document.
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
            Dim text As String = "Navigate to pdf2.pdf"
            textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
            status = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
                status = gdpicturePDF.GetStat()
            End If
            If (status = GdPictureStatus.OK) AndAlso
                (gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
                Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 0, 0)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", False, 1, 0, 0, 0, 0, 1)
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
                           (gdpicturePDF.SaveToFile("pdf1.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
                            MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption)
                            failure = False
                        End If
                    End If
                End If
            End If
        End If
    End If
End If
If failure Then
    MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat().ToString(), caption)
Else
    failure = True
    status = gdpicturePDF.NewPDF()
    If status = GdPictureStatus.OK Then
        'The creation of the second pdf2.pdf document.
        gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
        gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
        Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
        status = gdpicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
                Dim text As String = "Navigate to pdf1.pdf"
                textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
                    status = gdpicturePDF.GetStat()
                End If
                If (status = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
                    Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 0, 0)
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", False, 1, 0, 0, 0, 0, 1)
                        status = gdpicturePDF.GetStat()
                        If status = GdPictureStatus.OK Then
                            If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
                               (gdpicturePDF.SaveToFile("pdf2.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
                                MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption)
                                failure = False
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If
    If failure Then
        MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat(), caption)
    Else
        MessageBox.Show("The example HAS been successfully followed." + vbCrLf + "Both newly created PDF documents are linked together.", caption)
    End If
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionGoToR";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
bool failure = true;
float textSize = 12, textWidth = 0, textHeight = 0;
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    //The creation of the first pdf1.pdf document.
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
        {
            string text = "Navigate to pdf2.pdf";
            textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
            status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
            {
                textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
                status = gdpicturePDF.GetStat();
            }
            if ((status == GdPictureStatus.OK) &&
                (gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
            {
                int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 0, 0);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", false, 1, 0, 0, 0, 0, 1);
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                    {
                        if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
                            (gdpicturePDF.SaveToFile("pdf1.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
                        {
                            MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption);
                            failure = false;
                        }
                    }
                }
            }
        }
    }
}
if (failure)
    MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat().ToString(), caption);
else
{
    failure = true;
    status = gdpicturePDF.NewPDF();
    if (status == GdPictureStatus.OK)
    {
        //The creation of the second pdf2.pdf document.
        gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
        gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
        string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
        status = gdpicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
        {
            if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
                (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
                (gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
            {
                string text = "Navigate to pdf1.pdf";
                textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
                    status = gdpicturePDF.GetStat();
                }
                if ((status == GdPictureStatus.OK) &&
                    (gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
                {
                    int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 0, 0);
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                    {
                        int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", false, 1, 0, 0, 0, 0, 1);
                        status = gdpicturePDF.GetStat();
                        if (status == GdPictureStatus.OK)
                        {
                            if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
                                (gdpicturePDF.SaveToFile("pdf2.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
                            {
                                MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption);
                                failure = false;
                            }
                        }
                    }
                }
            }
        }
    }
    if (failure)
        MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat(), caption);
    else
        MessageBox.Show("The example HAS been successfully followed.\nBoth newly created PDF documents are linked together.", caption);
}
gdpicturePDF.Dispose();
See Also