GetActionPageDestination Method (GdPicturePDF)
In This Topic
Returns the information (a page number and a page view with the used coordinates) of the destination page of a specified action of the type GoTo, Named or
ExplicitDestination. These actions change the view of the currently loaded PDF document to a specified destination.
Syntax
'Declaration
Public Function GetActionPageDestination( _
ByVal As Integer, _
ByRef As PdfDestinationType, _
ByRef As Integer, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single, _
ByRef As Single _
) As GdPictureStatus
public GdPictureStatus GetActionPageDestination(
int ,
ref PdfDestinationType ,
ref int ,
ref float ,
ref float ,
ref float ,
ref float ,
ref float
)
public function GetActionPageDestination(
: Integer;
var : PdfDestinationType;
var : Integer;
var : Single;
var : Single;
var : Single;
var : Single;
var : Single
): GdPictureStatus;
public function GetActionPageDestination(
: int,
: PdfDestinationType,
: int,
: float,
: float,
: float,
: float,
: float
) : GdPictureStatus;
public: GdPictureStatus GetActionPageDestination(
int ,
ref PdfDestinationType ,
ref int ,
ref float ,
ref float ,
ref float ,
ref float ,
ref float
)
public:
GdPictureStatus GetActionPageDestination(
int ,
PdfDestinationType% ,
int% ,
float% ,
float% ,
float% ,
float% ,
float%
)
Parameters
- ActionID
- A unique action identifier specifying a required action object. You can obtain this identifier using these methods: GdPicturePDF.GetViewerOpenActionID, GdPicturePDF.GetBookmarkActionID, GdPicturePDF.GetFormFieldActionID, GdPicturePDF.GetAnnotationActionID, GdPicturePDF.NewActionGoTo or GdPicturePDF.NewActionNamed.
Please ensure that the type of the action object specified by this identifier is one of the action types PdfActionType.ActionTypeGoTo, PdfActionType.ActionTypeNamed or PdfActionType.ActionTypeExplicitDestination, otherwise the method will fail. You can check the type of the required action object using the GdPicturePDF.GetActionType method as it is shown in the example below.
- DestinationType
- Output parameter. A member of the PdfDestinationType enumeration. Sets up a particular view of a destination page specified by the used action mentioned above.
- Page
- Output parameter. The destination page number.
- Left
- Output 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.
- Bottom
- Output parameter. 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.
- Right
- Output parameter. 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.
- Top
- Output parameter. 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
- Output parameter. The zoom factor to use when displaying the destination page according to the DestinationType configuration.
The return value of 1 means 100% zoom, 2 means 200%, 0,5 for 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
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.
If the action object specified by the action identifier is not one of the correct action types mentioned above, the reason for the method's failure is GdPictureStatus.InvalidParameter.
Example
How to find out the destinations of all actions of type GoTo, Named or ExplicitDestination associated with the form fields in the PDF document.
Dim caption As String = "Example: GetActionPageDestination"
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 Actions 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
Select Case ActionType
Case PdfActionType.ActionTypeExplicitDestination, PdfActionType.ActionTypeGoTo, PdfActionType.ActionTypeNamed
'The GetActionPageDestination() method should only be used for these action types:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + vbCrLf
Dim DestType As PdfDestinationType = PdfDestinationType.DestinationTypeUndefined
Dim Page As Integer = -1
Dim Left As Single = 0, Bottom As Single = 0, Right As Single = 0, Top As Single = 0, Zoom As Single = 0
status = gdpicturePDF.GetActionPageDestination(ActionId, DestType, Page, Left, Bottom, Right, Top, Zoom)
If status = GdPictureStatus.OK Then
Actions = Actions + " Destination: " + DestType.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + vbCrLf
Else
Actions = Actions + " but the GetActionPageDestination() method has failed with the status: " + status.ToString() + vbCrLf
End If
Exit Select
Case Else
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action." + vbCrLf
Exit Select
End Select
End If
End If
End If
Next
MessageBox.Show(Actions, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionPageDestination";
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 Actions = "";
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)
{
switch (ActionType)
{
case PdfActionType.ActionTypeExplicitDestination:
case PdfActionType.ActionTypeGoTo:
case PdfActionType.ActionTypeNamed:
//The GetActionPageDestination() method should only be used for these action types:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + "\n";
PdfDestinationType DestType = PdfDestinationType.DestinationTypeUndefined;
int Page = -1;
float Left = 0, Bottom = 0, Right = 0, Top = 0, Zoom = 0;
status = gdpicturePDF.GetActionPageDestination(ActionId, ref DestType, ref Page, ref Left, ref Bottom, ref Right, ref Top, ref Zoom);
if (status == GdPictureStatus.OK)
{
Actions = Actions + " Destination: " + DestType.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + "\n";
}
else
{
Actions = Actions + " but the GetActionPageDestination() method has failed with the status: " + status.ToString() + "\n";
}
break;
default:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action.\n";
break;
}
}
}
}
}
MessageBox.Show(Actions, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Example
How to find out the destinations of all actions of type GoTo, Named or ExplicitDestination associated with the form fields in the PDF document.
Dim caption As String = "Example: GetActionPageDestination"
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 Actions 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
Select Case ActionType
Case PdfActionType.ActionTypeExplicitDestination, PdfActionType.ActionTypeGoTo, PdfActionType.ActionTypeNamed
'The GetActionPageDestination() method should only be used for these action types:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + vbCrLf
Dim DestType As PdfDestinationType = PdfDestinationType.DestinationTypeUndefined
Dim Page As Integer = -1
Dim Left As Single = 0, Bottom As Single = 0, Right As Single = 0, Top As Single = 0, Zoom As Single = 0
status = gdpicturePDF.GetActionPageDestination(ActionId, DestType, Page, Left, Bottom, Right, Top, Zoom)
If status = GdPictureStatus.OK Then
Actions = Actions + " Destination: " + DestType.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + vbCrLf
Else
Actions = Actions + " but the GetActionPageDestination() method has failed with the status: " + status.ToString() + vbCrLf
End If
Exit Select
Case Else
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action." + vbCrLf
Exit Select
End Select
End If
End If
End If
Next
MessageBox.Show(Actions, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionPageDestination";
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 Actions = "";
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)
{
switch (ActionType)
{
case PdfActionType.ActionTypeExplicitDestination:
case PdfActionType.ActionTypeGoTo:
case PdfActionType.ActionTypeNamed:
//The GetActionPageDestination() method should only be used for these action types:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + "\n";
PdfDestinationType DestType = PdfDestinationType.DestinationTypeUndefined;
int Page = -1;
float Left = 0, Bottom = 0, Right = 0, Top = 0, Zoom = 0;
status = gdpicturePDF.GetActionPageDestination(ActionId, ref DestType, ref Page, ref Left, ref Bottom, ref Right, ref Top, ref Zoom);
if (status == GdPictureStatus.OK)
{
Actions = Actions + " Destination: " + DestType.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + "\n";
}
else
{
Actions = Actions + " but the GetActionPageDestination() method has failed with the status: " + status.ToString() + "\n";
}
break;
default:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action.\n";
break;
}
}
}
}
}
MessageBox.Show(Actions, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also