I have a requirement to print to PDF from a custom print-preview window - which shows a collection of (GDI object) "Image"s in the .net 2.0 winform app.
All the samples seem great, but I didn't see one that would do this (what I thought was) simple task.
PdfDocument documentPDF = new PdfDocument(filename);
Graphics graphics = Graphics.FromImage(image);
XGraphics gfx = XGraphics.FromGraphics(graphics, new XSize(image.Width, image.Height));
PdfPage page = documentPDF.AddPage();
page.Size = PageSize.A4;
gfx.DrawImage(imageBmp, 0, 0);
but when trying to perform the last operation I get InvalidOperationException("Unsupported image format.") from XImage.
So if my image is made via GDI and I don't want to change much just to see if this works, how do I get my "emf" image into a pdf?