Home > DeveloperSection > Forums > Print something that is not shown on the screen using wpf.
Simons Hood
Simons Hood

Total Post:70

Posted on    August-16-2013 6:05 AM


 2 Reply(s)
 906  View(s)
Rate this:
Hi Developers!

How does word print all the content of the page? what is the mechanism? I just need a head start , how to print something that is not shown on the screen?

thanks in advance

shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    August-17-2013 6:58 AM


Im not sure if this is what you want but, 

What you have to do is create a dummy form that's the size of the control you want to print then add the control to the dummy form and show the form and print the control on the dummy. 

Here is how i did it: 

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)


    //Create bitmap

    Bitmap image = new Bitmap(dataGridView1.Width, dataGridView1.Height);

    //Create form

    Form f = new Form();

    //add datagridview to the form


    //set the size of the form to the size of the datagridview

    f.Size = dataGridView1.Size;

    //draw the datagridview to the bitmap

    dataGridView1.DrawToBitmap(image, new Rectangle(0, 0, dataGridView1.Width, dataGridView1.Height));

    //dispose the form



    e.Graphics.DrawImage(image, 0, 0);


This will print dataGridView1, even if its not seen on the form.

Ely Sanders

Total Post:3

Posted on    March-07-2014 6:10 AM

Hi, if you were referring to MS Word, it uses a C# word interop to manipulate with a content and to print it.
For your WPF application you need to use System.Printing namespace and its classes like PrintQueue and PrintTicket. You can read about it on MSDN Printing Overview.

Don't want to miss updates? Please click the below button!

Follow MindStick