empira / PDFsharp-1.5

A .NET library for processing PDF
MIT License
1.28k stars 588 forks source link

Copy a PDF Page Into Another PDF Page Box #173

Closed mxmissile closed 1 year ago

mxmissile commented 1 year ago

Does gfx.DrawImage(form,box) draw as an embedded image? If form is PDF content, does DrawImage draw as PDF content or a rasterized image?

I need to drop the contents of a page onto another pdf page within a box, is using XGraphics the way to go? Or is there a better way?

using (var form = XPdfForm.FromFile(drawingPath))
{
    using (var gfx = XGraphics.FromPdfPage(templatePage))
    {
        var box = new XRect(0, 0, 300, 300);
        gfx.DrawImage(form, box);
    }
}
ThomasHoevel commented 1 year ago

PDF content is drawn as PDF content when using gfx.DrawImage when outputting to PDF. PDF content can not be used when targeting a Graphics object or RTF.