GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / ScalePage Method
The horizontal scale factor, it corresponds to the page width.

For example, if this parameter is set to 2.0, it multiplies the page width of the currently selected page by 2, and if it is set to 0.5, it divides the page width by 2.

The vertical scale factor, it corresponds to the page height.

For example, if this parameter is set to 2.0, it multiplies the page height of the currently selected page by 2, and if it is set to 0.5, it divides the page height by 2.

Example





In This Topic
ScalePage Method (GdPicturePDF)
In This Topic
Scales (multiplies) the currently selected page in the loaded PDF document according to the specified scale factors for both page width and page height.
Syntax
'Declaration
 
Public Function ScalePage( _
   ByVal ScaleX As Single, _
   ByVal ScaleY As Single _
) As GdPictureStatus
public GdPictureStatus ScalePage( 
   float ScaleX,
   float ScaleY
)
public function ScalePage( 
    ScaleX: Single;
    ScaleY: Single
): GdPictureStatus; 
public function ScalePage( 
   ScaleX : float,
   ScaleY : float
) : GdPictureStatus;
public: GdPictureStatus ScalePage( 
   float ScaleX,
   float ScaleY
) 
public:
GdPictureStatus ScalePage( 
   float ScaleX,
   float ScaleY
) 

Parameters

ScaleX
The horizontal scale factor, it corresponds to the page width.

For example, if this parameter is set to 2.0, it multiplies the page width of the currently selected page by 2, and if it is set to 0.5, it divides the page width by 2.

ScaleY
The vertical scale factor, it corresponds to the page height.

For example, if this parameter is set to 2.0, it multiplies the page height of the currently selected page by 2, and if it is set to 0.5, it divides the page height by 2.

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 scale the first page in the PDF document.
Dim caption As String = "Example: ScalePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.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
                status = gdpicturePDF.ScalePage(0.5, 0.5)
                If status = GdPictureStatus.OK Then
                    If gdpicturePDF.SaveToFile("test_ScalePage.pdf") = GdPictureStatus.OK Then
                        MessageBox.Show("The page has been scaled successfully and the file has been saved.", caption)
                    Else
                        MessageBox.Show("The page has been scaled successfully, but the file can't be saved.", caption)
                    End If
                Else
                    MessageBox.Show("The ScalePage() method has failed with the status: " + status.ToString(), caption)
                    status = GdPictureStatus.OK
                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: ScalePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.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)
            {
                status = gdpicturePDF.ScalePage((float)0.5, (float)0.5);
                if (status == GdPictureStatus.OK)
                {
                    if (gdpicturePDF.SaveToFile("test_ScalePage.pdf") == GdPictureStatus.OK)
                        MessageBox.Show("The page has been scaled successfully and the file has been saved.", caption);
                    else
                        MessageBox.Show("The page has been scaled successfully, but the file can't be saved.", caption);
                }
                else
                {
                    MessageBox.Show("The ScalePage() 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