Printing a paper form (in BMP) from windows application. The Windows application plugs in values...

I have a BMP image (the form is also in PDF) that contains a scanned copy of a paper form that we need to fill out. Is it possible to use this image in my application so that the application can print out the form and the data that the user entered? For example, the user loads the application and a normal Windows Form asks for the user's name. When the user enters the name
and clicks on the "Print" button, I'd like to print the form in the jpg
image and include the person's name in that form (in the appropriate
I wanted to use a Windows Form (whose background would be the image), add a
textbox, and then print the Windows Form (with the txtbox that includes the
user's name), but the Windows Form's size is limited to the screen
Someone suggested using PrintDocument but from what I understand, that'll only print the document. I still need to insert some values at run-time before printing it.
Any suggestions are appreciated.
Who is Participating?
PAQed, with points refunded (100)

E-E Admin
Here is an example from MSDN.

Hope it Helps.

Good Luck

public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
   Graphics mygraphics = this.CreateGraphics();
   Size s = this.Size;
   memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
   Graphics memoryGraphics = Graphics.FromImage(memoryImage);
   IntPtr dc1 = mygraphics.GetHdc();
   IntPtr dc2 = memoryGraphics.GetHdc();
   BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
private void printDocument1_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
   e.Graphics.DrawImage(memoryImage, 0, 0);
private void printButton_Click(System.Object sender, System.EventArgs e)
Compiling the Code
This example requires:

A PrintDocument component named printDocument1 with a PrintPage event handler.
A Button named printButton with a Click event handler.
The example code replaces the existing event handlers. The form is printed when printButton is clicked.

Robust Programming
The following conditions may cause an exception:

You do not have permission to access the printer.
You do not have permission to use unmanaged code.
There is no printer installed.
In order to run this example, you must have permission to execute unmanaged code and to access the printer.

MyersAAuthor Commented:
Thanks for the info.
It didn't work quite as expected. First, it prints out the Windows taskbar. Also, Form class limits the size of the form so it's not larger than the screen size, so I won't be ablt to create a form that's as big as the bmp I'll be importing. And I don't think I can plug in the values during runtime.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.