Is there an easy way to use Infragistics.Documents to export a Windows Form (as it appears on screen) directly to a PDF? I assume I could grab the image of the form and add that to the PDF. Does anyone have any sample code that illustrates how to do this?
Hi,
heres a code snippet, that creates a bitmap of a control (which could be a windows form)
public Bitmap CreateScreenshot(Control control) { int width = control.Width; int height = control.Height; Bitmap bmp = new Bitmap(width, heigth); control.DrawToBitmap(bmp, Rectangle.FromLTRB(0, 0, width, heigth)); return bmp; }
you would call it like this from your form
Bitmap bmp = CreateScreenshot(this);
Obviously you can create a bitmap from your form and maybe this is good enough. But you are leaving out all the vectorized advantages that a PDF supports. Your text quality will be garbage, and you won't be able to search on any text.
You can save the drawings of your controls as a vectorized metafile (and retain the textual content), but at present you can't fully render these to a a PDF using Infragistics.Documents.
I won't say who, but there are several other component vendors that can render the majority of GDI commands required to draw a form in it's entirerty to a PDF.
I've submited this as a feature for Infragistics.Documents...if you are interested in this feature maybe you can too,
For more details see my posting: http://forums.infragistics.com/forums/t/1461.aspx