GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SetViewerOpenAction Method
A unique action identifier specifying a required action object. You can obtain this identifier when creating an action, for example, using the NewActionGoTo(PdfDestinationType,Int32,Single,Single,Single,Single,Single) method.
Example





In This Topic
SetViewerOpenAction Method (GdPicturePDF)
In This Topic
Sets the specified action in the OpenAction entry in the PDF document's catalog. This property defines a destination to be displayed or an action to be carried out when the document is opened. If this entry is absent, the document should be opened to the top of the first page at the default magnification factor.
Syntax
'Declaration
 
Public Function SetViewerOpenAction( _
   ByVal ActionID As Integer _
) As GdPictureStatus
public GdPictureStatus SetViewerOpenAction( 
   int ActionID
)
public function SetViewerOpenAction( 
    ActionID: Integer
): GdPictureStatus; 
public function SetViewerOpenAction( 
   ActionID : int
) : GdPictureStatus;
public: GdPictureStatus SetViewerOpenAction( 
   int ActionID
) 
public:
GdPictureStatus SetViewerOpenAction( 
   int ActionID
) 

Parameters

ActionID
A unique action identifier specifying a required action object. You can obtain this identifier when creating an action, for example, using the NewActionGoTo(PdfDestinationType,Int32,Single,Single,Single,Single,Single) method.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to set the OpenAction action of a PDF to open it at the 10th page, with a zoom level of 300% and a default offset set to 1 centimeter from the left and 5 centimeters from the top.
Dim caption As String = "Example: SetViewerOpenAction"
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: SetViewerOpenAction";
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();
See Also