GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / NewActionGoTo Method / NewActionGoTo(PdfDestinationType,Int32,Single,Single,Single,Single,Single) Method
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination page specified by the Page parameter.
The destination page number in the current document. It must be a value from 1 to GetPageCount.
The horizontal (left) coordinate of the document window's position according to the specified DestinationType parameter. 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 specified DestinationType parameter. 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 specified DestinationType parameter. 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 specified DestinationType parameter. 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
NewActionGoTo(PdfDestinationType,Int32,Single,Single,Single,Single,Single) Method
In This Topic
Creates a new action of the type GoTo. A go-to action changes the view to a specified destination (page, location, and magnification factor) in the currently loaded PDF document.
Syntax
'Declaration
 
Public Overloads Function NewActionGoTo( _
   ByVal DestinationType As PdfDestinationType, _
   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 NewActionGoTo( 
   PdfDestinationType DestinationType,
   int Page,
   float Left,
   float Right,
   float Bottom,
   float Top,
   float Zoom
)
public function NewActionGoTo( 
    DestinationType: PdfDestinationType;
    Page: Integer;
    Left: Single;
    Right: Single;
    Bottom: Single;
    Top: Single;
    Zoom: Single
): Integer; 
public function NewActionGoTo( 
   DestinationType : PdfDestinationType,
   Page : int,
   Left : float,
   Right : float,
   Bottom : float,
   Top : float,
   Zoom : float
) : int;
public: int NewActionGoTo( 
   PdfDestinationType DestinationType,
   int Page,
   float Left,
   float Right,
   float Bottom,
   float Top,
   float Zoom
) 
public:
int NewActionGoTo( 
   PdfDestinationType DestinationType,
   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 page specified by the Page parameter.
Page
The destination page number in the current document. It must be a value from 1 to GetPageCount.
Left
The horizontal (left) coordinate of the document window's position according to the specified DestinationType parameter. 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 specified DestinationType parameter. 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 specified DestinationType parameter. 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 specified DestinationType parameter. 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 GoTo. 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 and set the OpenAction action within a PDF document to open it at the 10th page, with a zoom level of 300% and default offset set to 1 centimeter from the left and 5 centimeters from the top.
Dim caption As String = "Example: NewActionGoTo"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("testPDF.pdf", False)
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, 10, 1, 0, 0, 5, 3)
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        status = gdpicturePDF.SetViewerOpenAction(actionID)
        If status = GdPictureStatus.OK Then
            If gdpicturePDF.SaveToFile("open_action.pdf") = GdPictureStatus.OK Then
                MessageBox.Show("The PDF document with the specified OpenAction has been saved successfully.", caption)
            Else
                MessageBox.Show("The file can't be saved.", caption)
            End If
        Else
            MessageBox.Show("The SetViewerOpenAction() method has failed with the status: " + status.ToString(), caption)
        End If
    Else
        MessageBox.Show("The NewActionGoTo() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionGoTo";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("testPDF.pdf", false);
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, 10, 1, 0, 0, 5, 3);
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        status = gdpicturePDF.SetViewerOpenAction(actionID);
        if (status == GdPictureStatus.OK)
        {
            if (gdpicturePDF.SaveToFile("open_action.pdf") == GdPictureStatus.OK)
            {
                MessageBox.Show("The PDF document with the specified OpenAction has been saved successfully.", caption);
            }
            else
            {
                MessageBox.Show("The file can't be saved.", caption);
            }
        }
        else
        {
            MessageBox.Show("The SetViewerOpenAction() method has failed with the status: " + status.ToString(), caption);
        }
            
    }
    else
    {
        MessageBox.Show("The NewActionGoTo() method has failed with the status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
How to create and associate a GoTo action with a bookmark. The example shows you the creation of the 10 pages PDF document with bookmarks, where each bookmark locates a specific page.
Dim caption As String = "Example: NewActionGoTo"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim failure As Boolean = True
        Dim i As Integer = 0
        Do
            i += 1
            If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
               (gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) = GdPictureStatus.OK) Then
                Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    Dim bookMarkID As Integer = gdpicturePDF.NewBookmark(0, "Move to the page " + i.ToString())
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        status = gdpicturePDF.SetBookmarkAction(bookMarkID, actionID)
                        failure = (status <> GdPictureStatus.OK)
                    End If
                End If
            End If
            If failure Then
                MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Loop While Not failure AndAlso i < 10
        If Not failure AndAlso (gdpicturePDF.SaveToFile("bookmarks_actions.pdf") = GdPictureStatus.OK) Then
            MessageBox.Show("The new file has been saved successfully.", caption)
        Else
            MessageBox.Show("The new file can't be saved.", caption)
        End If
    Else
        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The new file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionGoTo";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        bool failure = true;
        int i = 0;
        do
        {
            i++;
            if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
                (gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
                (gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
                (gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) == GdPictureStatus.OK))
            {
                int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    int bookMarkID = gdpicturePDF.NewBookmark(0, "Move to the page " + i.ToString());
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                    {
                        status = gdpicturePDF.SetBookmarkAction(bookMarkID, actionID);
                        failure = (status != GdPictureStatus.OK);
                    }
                }
            }
            if (failure)
            {
                MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption);
            }
        } while (!failure && i < 10);
        if (!failure && (gdpicturePDF.SaveToFile("bookmarks_actions.pdf") == GdPictureStatus.OK))
        {
            MessageBox.Show("The new file has been saved successfully.", caption);
        }
        else
        {
            MessageBox.Show("The new file can't be saved.", caption);
        }
    }
    else
    {
        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The new file can't be created.", caption);
}
gdpicturePDF.Dispose();
See Also