pdfsharp team,
does XGraphics.FromGraphics works if i want to use it to replace XGraphics.FromPdfPage.
It seemed like it works differently. XGraphics i created XGraphics.FromPdfPage displayed correctly but not when i do XGraphics.FromGraphics. if it not working, what can i do if i want to save an XGraphics work to an image file instead of PDF Page.
==============================================
/// this works
public void Render(PdfPage page)
{
this.gfx = XGraphics.FromPdfPage(page);
CreateGraphics(this.gfx);
}
/// this DOES NOT, it creates an empty image
public void Render(string filename)
{
this.mergedCells = new MergedCellList(this.table);
XSize size = new XSize();
size.Width = 500;
size.Height = 500;
Bitmap bmp = new Bitmap((int)500, (int)500);
Graphics gImg = Graphics.FromImage(bmp);
gImg.Clear(Color.Transparent);
this.gfx = XGraphics.FromGraphics(gImg, size);
CreateGraphics(this.gfx);
bmp.Save(filename,System.Drawing.Imaging.ImageFormat.Jpeg);
// Save to JPEG
gImg.Dispose();
bmp.Dispose();
}
best regards,
purna
|