Open Martinus-Novakus opened 2 years ago
Have a similar issue as @Martinus-Novakus:
var document = new PdfDocument();
var page = document.AddPage();
var form = new XForm(document, page.Width, page.Height);
var font = new XFont("OpenSans", 20, XFontStyle.Bold);
var formGfx = XGraphics.FromForm(form);
formGfx.DrawString(
"Hello World!", font, XBrushes.Black,
new XRect(0, 0, form.PixelWidth, form.PixelHeight),
XStringFormats.Center);
formGfx.Dispose();
var pageGfx = XGraphics.FromPdfPage(page);
pageGfx.DrawImage(form, 0, 0);
pageGfx.Dispose();
document.Save("test.pdf");
Using .NET 5, the previous code delivers a test.pdf, showing "Hello World!" (as expected) Using .NET 6, the previous code delivers a much smaller test.pdf (regarding filesize), showing nothing.
UPDATE: ... wild guess: this could have sth. to do with it: https://github.com/ststeiger/PdfSharpCore/blob/90eb7dbb98fc5eeb18e2ee20c69018916a4865cc/PdfSharpCore/Drawing/XGraphics.cs#L210
UPDATE 2: after fixing and testing it, that was the issue. PR https://github.com/ststeiger/PdfSharpCore/pull/295 should solve it
Hi, I have a problem with rendering XForm into a PdfPage. First I draw image into XForm, then i try to draw XForm into PdfPage of a PdfDocument. After saving the document, the page is empty.
I am trying it in a small sample project and I think I have followed the documentation exactly. Please tell me what I am doing wrong.
PS: I also tried drawing the same image right into the PdfPage, which worked as expected and image was there.