PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

XGraphics.FromGraphics
https://forum.pdfsharp.net/viewtopic.php?f=2&t=165
Page 1 of 1

Author:  purnal [ Mon Jun 11, 2007 8:19 pm ]
Post subject:  XGraphics.FromGraphics

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/