GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / GetPageBox Method
The required page (boundary) box. A member of the PdfPageBox enumeration.
Output parameter. The horizontal (X) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The vertical (Y) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The horizontal (X) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The vertical (Y) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Example





In This Topic
GetPageBox Method (GdPicturePDF)
In This Topic
Returns the boundaries, expressed in the current units used in this document, of the specified page box of the currently selected page of the loaded PDF document.

You can simply use the GdPicturePDF.GetMeasurementUnit method to determine the currently defined units or you can easily use the GdPicturePDF.SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration
 
Public Function GetPageBox( _
   ByVal PageBox As PdfPageBox, _
   ByRef Left As Single, _
   ByRef Top As Single, _
   ByRef Right As Single, _
   ByRef Bottom As Single _
) As GdPictureStatus
public GdPictureStatus GetPageBox( 
   PdfPageBox PageBox,
   ref float Left,
   ref float Top,
   ref float Right,
   ref float Bottom
)
public function GetPageBox( 
    PageBox: PdfPageBox;
   var  Left: Single;
   var  Top: Single;
   var  Right: Single;
   var  Bottom: Single
): GdPictureStatus; 
public function GetPageBox( 
   PageBox : PdfPageBox,
   Left : float,
   Top : float,
   Right : float,
   Bottom : float
) : GdPictureStatus;
public: GdPictureStatus GetPageBox( 
   PdfPageBox PageBox,
   ref float Left,
   ref float Top,
   ref float Right,
   ref float Bottom
) 
public:
GdPictureStatus GetPageBox( 
   PdfPageBox PageBox,
   float% Left,
   float% Top,
   float% Right,
   float% Bottom
) 

Parameters

PageBox
The required page (boundary) box. A member of the PdfPageBox enumeration.
Left
Output parameter. The horizontal (X) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Top
Output parameter. The vertical (Y) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Right
Output parameter. The horizontal (X) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Bottom
Output parameter. The vertical (Y) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit 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.

The output values are always calulated with respect to the default bottom-left origin. SetOrigin method does not affect the results in any way.

Just to remind you that 1 point is equivalent to 1/72 of an inch.

Example
How to obtain the mediabox and the cropbox boundaries of the first page in your document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    Dim message As String = ""
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
    status = gdpicturePDF.SelectPage(1)
    If status = GdPictureStatus.OK Then
        Dim left As Single = 0, top As Single = 0, right As Single = 0, bottom As Single = 0
        status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, left, top, right, bottom)
        If status = GdPictureStatus.OK Then
            message = message + "The mediabox for the first page is defined like this:" + vbCrLf + "( " + left.ToString() + " ; " + top.ToString() +
                                " ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters."
        Else
            message = message + "The GetPageBox() method for mediabox has failed with the status: " + status.ToString()
        End If
            
        status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, left, top, right, bottom)
        If status = GdPictureStatus.OK Then
            message = message + vbCrLf + "The cropbox  for the first page is defined like this:" + vbCrLf + "( " + Left.ToString() + " ; " + top.ToString() +
                                         " ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters."
        Else
            message = message + vbCrLf + "The GetPageBox() method for cropbox has failed with the status: " + status.ToString()
        End If
    Else
        message = message + "The SelectPage() method has failed with the status: " + status.ToString()
    End If
    MessageBox.Show(message, "Example: GetPageBox")
Else
    MessageBox.Show("The file can't be loaded.", "Example: GetPageBox")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    string message = "";
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
    status = gdpicturePDF.SelectPage(1);
    if (status == GdPictureStatus.OK)
    {
        float left = 0, top = 0, right = 0, bottom = 0;
        status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref left, ref top, ref right, ref bottom);
        if (status == GdPictureStatus.OK)
        {
            message = message + "The mediabox for the first page is defined like this:\n( " + left.ToString() + " ; " + top.ToString() +
                                " ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters.";
        }
        else
            message = message + "The GetPageBox() method for mediabox has failed with the status: " + status.ToString();
            
        status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, ref left, ref top, ref right, ref bottom);
        if (status == GdPictureStatus.OK)
        {
            message = message + "\nThe cropbox  for the first page is defined like this:\n( " + left.ToString() + " ; " + top.ToString() +
                                " ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters.";
            
        }
        else
            message = message + "\nThe GetPageBox() method for cropbox has failed with the status: " + status.ToString();
    }
    else
        message = message + "The SelectPage() method has failed with the status: " + status.ToString();
    MessageBox.Show(message, "Example: GetPageBox");
}
else
    MessageBox.Show("The file can't be loaded.", "Example: GetPageBox");
gdpicturePDF.Dispose();
See Also