Skip to main content
A newer version of this page is available. .
All docs
V20.2
.NET Framework 4.5.2+

PdfGraphics.DrawPageContent(PdfPage) Method

Draws the specified page’s content.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v20.2.Drawing.dll

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public void DrawPageContent(
    PdfPage source
)

Parameters

Name Type Description
source PdfPage

The source page from which content is drawn.

Remarks

Use this method to add the page content to the document. Call the PdfGraphics.AddToPageForeground method to draw the resulting graphics in the document.

Call the PdfDocumentProcessor.FlattenForm() method to flatten interactive forms. Otherwise, interactive forms are ignored.

The code sample below shows how to insert page content from one document into another. The source content is scaled and added to the end of the target page.

result

using DevExpress.Pdf;
using System.Drawing;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    processor.CreateEmptyDocument();
    PdfPage page = processor.AddNewPage(PdfPaperSize.A4);
    using (PdfDocumentProcessor processor2 = new PdfDocumentProcessor())
    {
        processor2.LoadDocument(@"Demo.pdf");
        using (PdfGraphics graphics = processor.CreateGraphics())
        {
            graphics.SaveGraphicsState();

            //Define the position to insert the content on a target page:
            graphics.TranslateTransform((float)(page.CropBox.Width * 1 / 3), (float)(page.CropBox.Height * 4 / 5));
            PdfRectangle clip = processor2.Document.Pages[0].CropBox;

            //Resize the source page content to fit the target page:
            graphics.ScaleTransform((float)(page.CropBox.Width / clip.Width / 3), (float)(page.CropBox.Width / clip.Width / 3));

            //Crop the source content to insert the third of the page:
            graphics.IntersectClip(new RectangleF((float)clip.Left, (float)(clip.Top / 2.8), (float)clip.Width, (float)(clip.Height / 2.8)));

            //Draw the cropped segment in the target page:
            graphics.DrawPageContent(processor2.Document.Pages[0]);
            graphics.RestoreGraphicsState();

            //Apply the changes:
            graphics.AddToPageForeground(page, 72, 72);
        }
    }
    processor.SaveDocument("out2.pdf");
}
See Also