Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
"Print" a Windows Form to PDF
posted

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?

Parents
  • 1922
    posted

    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);

Reply Children
No Data