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

SetPageBox Method (GdPicturePDF)

In This Topic
Sets the new boundaries, expressed in the current units used in this document, of the required page box of the currently selected page of the loaded PDF document.

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

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

Parameters

PageBox
The required page (boundary) box. A member of the PdfPageBox enumeration.
Left
The newly defined horizontal (X) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Top
The newly defined vertical (Y) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Right
The newly defined horizontal (X) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Bottom
The newly defined 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 input values should always respect the default bottom-left origin. SetOrigin method does not affect the results of this method in any way.

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

Example
How to reset the cropbox boundaries of the cloned 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.ClonePage(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.PdfPageBoxCropBox, left, top, right, bottom)
        If status = GdPictureStatus.OK Then
            status = gdpicturePDF.SetPageBox(PdfPageBox.PdfPageBoxCropBox, left + 10, top - 10, right - 10, bottom + 10)
            If status = GdPictureStatus.OK Then
                If status = GdPictureStatus.OK Then
                    If gdpicturePDF.SaveToFile("test_SetPageBox.pdf") = GdPictureStatus.OK Then
                        message = message + "The example has been followed successfully and file has been saved."
                    Else
                        message = message + "The example has been followed successfully but the file can't be saved."
                    End If
            
                End If
            Else
                message = message + "The SetPageBox() method has failed with the status: " + status.ToString()
            End If
            Else
            message = message + "The GetPageBox() method has failed with the status: " + status.ToString()
        End If
    Else
        message = message + "The ClonePage() 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: SetPageBox")
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.ClonePage(1);
    if (status == GdPictureStatus.OK)
    {
        float left = 0, top = 0, right = 0, bottom = 0;
        status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, ref left, ref top, ref right, ref bottom);
        if (status == GdPictureStatus.OK)
        {
            status = gdpicturePDF.SetPageBox(PdfPageBox.PdfPageBoxCropBox, left + 10, top - 10, right - 10, bottom + 10);
            if (status == GdPictureStatus.OK)
            {
                if (status == GdPictureStatus.OK)
                {
                    if (gdpicturePDF.SaveToFile("test_SetPageBox.pdf") == GdPictureStatus.OK)
                        message = message + "The example has been followed successfully and file has been saved.";
                    else
                        message = message + "The example has been followed successfully but the file can't be saved.";
                }
            
            }
            else
                message = message + "The SetPageBox() method has failed with the status: " + status.ToString();
        }
        else
            message = message + "The GetPageBox() method has failed with the status: " + status.ToString();
    }
    else
        message = message + "The ClonePage() method has failed with the status: " + status.ToString();
    MessageBox.Show(message, "Example: GetPageBox");
}
else
    MessageBox.Show("The file can't be loaded.", "Example: SetPageBox");
gdpicturePDF.Dispose();
See Also