GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / DrawPage Method
The source PDF document, which contains the source page to draw.
The page number of the page, which content is to be drawn. This parameter is without any restrictions, the source page is selected by use of the SelectPage method, so all there mentioned details remain in effect.
The horizontal (X) coordinate of the bottom left point of the destination area, where the page content is to be drawn, expressed in the current units used in the destination PDF document, related to the currently selected page.
The vertical (Y) coordinate of the bottom left point of the destination area, where the page content is to be drawn, expressed in the current units used in the destination PDF document, related to the currently selected page.
The width of the destination area, expressed in the current units used in the destination PDF document.
The height of the destination area, expressed in the current units used in the destination PDF document.
Example





In This Topic
DrawPage Method (GdPicturePDF)
In This Topic
Draws content of the page, specified by its page number, from a source PDF document, onto the exactly defined area of the currently selected page of the destination PDF document. The coordinates and the dimensions of the destination area need to be set in the current units defined in the destination PDF document, related to the actual page, where the content of the source page is to be drawn.

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

Syntax
'Declaration
 
Public Function DrawPage( _
   ByVal SrcPDF As GdPicturePDF, _
   ByVal SrcPage As Integer, _
   ByVal DstX As Single, _
   ByVal DstY As Single, _
   ByVal DstWidth As Single, _
   ByVal DstHeight As Single _
) As GdPictureStatus
public GdPictureStatus DrawPage( 
   GdPicturePDF SrcPDF,
   int SrcPage,
   float DstX,
   float DstY,
   float DstWidth,
   float DstHeight
)
public function DrawPage( 
    SrcPDF: GdPicturePDF;
    SrcPage: Integer;
    DstX: Single;
    DstY: Single;
    DstWidth: Single;
    DstHeight: Single
): GdPictureStatus; 
public function DrawPage( 
   SrcPDF : GdPicturePDF,
   SrcPage : int,
   DstX : float,
   DstY : float,
   DstWidth : float,
   DstHeight : float
) : GdPictureStatus;
public: GdPictureStatus DrawPage( 
   GdPicturePDF* SrcPDF,
   int SrcPage,
   float DstX,
   float DstY,
   float DstWidth,
   float DstHeight
) 
public:
GdPictureStatus DrawPage( 
   GdPicturePDF^ SrcPDF,
   int SrcPage,
   float DstX,
   float DstY,
   float DstWidth,
   float DstHeight
) 

Parameters

SrcPDF
The source PDF document, which contains the source page to draw.
SrcPage
The page number of the page, which content is to be drawn. This parameter is without any restrictions, the source page is selected by use of the SelectPage method, so all there mentioned details remain in effect.
DstX
The horizontal (X) coordinate of the bottom left point of the destination area, where the page content is to be drawn, expressed in the current units used in the destination PDF document, related to the currently selected page.
DstY
The vertical (Y) coordinate of the bottom left point of the destination area, where the page content is to be drawn, expressed in the current units used in the destination PDF document, related to the currently selected page.
DstWidth
The width of the destination area, expressed in the current units used in the destination PDF document.
DstHeight
The height of the destination area, expressed in the current units used in the destination PDF document.

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, both the source and the destination one.

Be aware that DstX and DstY parameters are fixly determined as the coordinates of the bottom left point of the destination area on the actual page.

This method requires the Document Editor component to run.

Example
How to draw content of the first page of the source PDF document onto the first page of the destination PDF document twice, side by side, within the two same-sized areas.
Dim caption As String = "Example: DrawPage"
Dim srcPDF As New GdPicturePDF()
Dim dstPDF As New GdPicturePDF()
Dim status As GdPictureStatus = srcPDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    If (dstPDF.NewPDF() = GdPictureStatus.OK) AndAlso
       (dstPDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
        Dim width As Single = dstPDF.GetPageWidth()
        If dstPDF.GetStat() = GdPictureStatus.OK Then
            Dim height As Single = dstPDF.GetPageHeight()
            If dstPDF.GetStat() = GdPictureStatus.OK Then
                'the new width of the destination area
                width = width / 2
                If (dstPDF.SelectPage(1) = GdPictureStatus.OK) AndAlso
                   (dstPDF.DrawPage(srcPDF, 1, 0, 0, width, height) = GdPictureStatus.OK) AndAlso
                   (dstPDF.DrawPage(srcPDF, 1, width, 0, width, height) = GdPictureStatus.OK) Then
                    status = dstPDF.SaveToFile("test_DrawPage.pdf")
                    If status = GdPictureStatus.OK Then
                        MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
                    Else
                        MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
                    End If
                Else
                    MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + dstPDF.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("The GetPageHeight() method has failed with the status: " + dstPDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("The GetPageWidth() method has failed with the status: " + dstPDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The NewPDF() method or the NewPage() for the destination document has failed with the status: " + dstPDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The LoadFromFile() method for the source document has failed with the status: " + status.ToString(), caption)
End If
srcPDF.Dispose()
dstPDF.Dispose()
string caption = "Example: DrawPage";
GdPicturePDF srcPDF = new GdPicturePDF();
GdPicturePDF dstPDF = new GdPicturePDF();
GdPictureStatus status = srcPDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    if ((dstPDF.NewPDF() == GdPictureStatus.OK) &&
        (dstPDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
    {
        float width = dstPDF.GetPageWidth();
        if (dstPDF.GetStat() == GdPictureStatus.OK)
        {
            float height = dstPDF.GetPageHeight();
            if (dstPDF.GetStat() == GdPictureStatus.OK)
            {
                //the new width of the destination area
                width = width / 2;
                if ((dstPDF.SelectPage(1) == GdPictureStatus.OK) &&
                    (dstPDF.DrawPage(srcPDF, 1, 0, 0, width, height) == GdPictureStatus.OK) &&
                    (dstPDF.DrawPage(srcPDF, 1, width, 0, width, height) == GdPictureStatus.OK))
                {
                    status = dstPDF.SaveToFile("test_DrawPage.pdf");
                    if (status == GdPictureStatus.OK)
                        MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
                    else
                        MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
                }
                else
                    MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + dstPDF.GetStat().ToString(), caption);
            }
            else
                MessageBox.Show("The GetPageHeight() method has failed with the status: " + dstPDF.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("The GetPageWidth() method has failed with the status: " + dstPDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The NewPDF() method or the NewPage() for the destination document has failed with the status: " + dstPDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The LoadFromFile() method for the source document has failed with the status: " + status.ToString(), caption);
srcPDF.Dispose();
dstPDF.Dispose();
See Also