Is there a way to render content onto an XGraphics and then use the XGraphics to render it again on different pages of the PDF?

118 Views Asked by At

As the title says, I've drawn some text onto an PdfSharp.Drawing.XGraphics object. Is it possible to put that text onto another part of the PDF without having to draw it all again? The underlying System.Drawing.Graphic method AddMetafileComment implies there might be a metafile somewhere buried below the surface. But I can't see a way to access it. Does XGraphics.CreateMeasureContext help at all?

I'm using PdfSharp-gdi.1.50.5147.0.

1

There are 1 best solutions below

0
I liked the old Stack Overflow On

XGraphics objects execute the drawing instructions directly. There is no "macro recorder" and AFAIK metafiles are not supported.

With PDFsharp, you can create an XForm object and draw that on multiple PDF pages.
https://pdfsharp.net/wiki/XForms-sample.ashx