GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / ResizePage Method
The new required page width expressed in the current units specified by the SetMeasurementUnit method.

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

The new required page height expressed in the current units specified by the SetMeasurementUnit method.

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

Example





In This Topic
ResizePage Method (GdPicturePDF)
In This Topic
Resizes the currently selected page in the loaded PDF document according to the newly specified page width and page height.
Syntax
'Declaration
 
Public Function ResizePage( _
   ByVal NewPageWidth As Single, _
   ByVal NewPageHeight As Single _
) As GdPictureStatus
public GdPictureStatus ResizePage( 
   float NewPageWidth,
   float NewPageHeight
)
public function ResizePage( 
    NewPageWidth: Single;
    NewPageHeight: Single
): GdPictureStatus; 
public function ResizePage( 
   NewPageWidth : float,
   NewPageHeight : float
) : GdPictureStatus;
public: GdPictureStatus ResizePage( 
   float NewPageWidth,
   float NewPageHeight
) 
public:
GdPictureStatus ResizePage( 
   float NewPageWidth,
   float NewPageHeight
) 

Parameters

NewPageWidth
The new required page width expressed in the current units specified by the SetMeasurementUnit method.

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

NewPageHeight
The new required page height expressed in the current units specified by the SetMeasurementUnit method.

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

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.

This method requires the Document Editor component to run.

Example
How to resize the first page in the PDF document.
Dim caption As String = "Example: ResizePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        If count > 0 Then
            status = gdpicturePDF.SelectPage(1)
            If status = GdPictureStatus.OK Then
                Dim height As Single = gdpicturePDF.GetPageHeight()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    Dim width As Single = gdpicturePDF.GetPageWidth()
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        status = gdpicturePDF.ResizePage(width / 2, height / 2)
                        If status = GdPictureStatus.OK Then
                            If gdpicturePDF.SaveToFile("test_ResizePage.pdf") = GdPictureStatus.OK Then
                                MessageBox.Show("The page has been resized successfully and the file has been saved.", caption)
                            Else
                                MessageBox.Show("The page has been resized successfully, but the file can't be saved.", caption)
                            End If
                        Else
                            MessageBox.Show("The ResizePage() method has failed with the status: " + status.ToString(), caption)
                            status = GdPictureStatus.OK
                        End If
                    End If
                End If
            End If
        Else
            status = GdPictureStatus.InvalidParameter
        End If
    End If
    If status <> GdPictureStatus.OK Then
        MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ResizePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("testPDF.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetPageCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        if (count > 0)
        {
            status = gdpicturePDF.SelectPage(1);
            if (status == GdPictureStatus.OK)
            {
                float height = gdpicturePDF.GetPageHeight();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    float width = gdpicturePDF.GetPageWidth();
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                    {
                        status = gdpicturePDF.ResizePage(width/2, height/2);
                        if (status == GdPictureStatus.OK)
                        {
                            if (gdpicturePDF.SaveToFile("test_ResizePage.pdf") == GdPictureStatus.OK)
                                MessageBox.Show("The page has been resized successfully and the file has been saved.", caption);
                            else
                                MessageBox.Show("The page has been resized successfully, but the file can't be saved.", caption);
                        }
                        else
                        {
                            MessageBox.Show("The ResizePage() method has failed with the status: " + status.ToString(), caption);
                            status = GdPictureStatus.OK;
                        }
                    }
                }
            }
        }
        else
            status = GdPictureStatus.InvalidParameter;
    }
    if (status != GdPictureStatus.OK)
        MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also