By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,669 Members | 2,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,669 IT Pros & Developers. It's quick & easy.

Printing a paper form (in BMP) from windows application

P: n/a
VMI
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
position).
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
resolution.
Someone suggested using PrintDocument but I'm not sure if it'll be able to
accomplish this.
Any suggestions are appreciated.
Thanks.
BTW, the PDF that contains the form is editable through Acrobat Reader (I
can type into it and print). Maybe that'll help me.
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
VMI,
You can use PrintDocument and just print the bitmap at the appropriate
location on the form. Make sure to adjust for the printer's dpi settings
though or you will get stretching/shrinking effects on the background. You
can use DpiX and DpiY properties of the Graphics from the PrintPageEventArgs
argument to OnPrintPage to get the resolutions.

Ron Allen
"VMI" <vo******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP15.phx.gbl...
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
position).
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
resolution.
Someone suggested using PrintDocument but I'm not sure if it'll be able to
accomplish this.
Any suggestions are appreciated.
Thanks.
BTW, the PDF that contains the form is editable through Acrobat Reader (I
can type into it and print). Maybe that'll help me.

Nov 16 '05 #2

P: n/a
VMI
The bitmap I'll be printing is an 8.5"X11" form. I don't really need to
display it in the Win Form; I just need to print it with the user
information. So I'm not really sure what you mean by that. Do you know of
any examples on the Web?

Thanks.
"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
VMI,
You can use PrintDocument and just print the bitmap at the appropriate
location on the form. Make sure to adjust for the printer's dpi settings
though or you will get stretching/shrinking effects on the background. You can use DpiX and DpiY properties of the Graphics from the PrintPageEventArgs argument to OnPrintPage to get the resolutions.

Ron Allen
"VMI" <vo******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP15.phx.gbl...
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
position).
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
resolution.
Someone suggested using PrintDocument but I'm not sure if it'll be able to accomplish this.
Any suggestions are appreciated.
Thanks.
BTW, the PDF that contains the form is editable through Acrobat Reader (I can type into it and print). Maybe that'll help me.


Nov 16 '05 #3

P: n/a
VMI,
Sorry I meant page where I said form. I don't know of any examples
offhand on the web but I haven't had any problems printing bitmaps on a page
using PrintDocument.
For example the following puts a logo on the page if the logo file
exists on the disk and then sets the x location to just past the right hand
side of the logo.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.Xml;
if (System.IO.File.Exists(logoName)) // either specified or stock.
{
Image img = Image.FromFile(logoName);
e.Graphics.DrawImage(img, new PointF(98.0f, 56.5f));
xloc = 1.0f + (img.Width/img.HorizontalResolution) + 0.05f;
}
This puts it at the top left of the page for this form. In your case I
guess that you would just draw the whole thing at 0,0 but be aware that
things outside the printer's hard margins won't be shown.

Ron Allen

"VMI" <vo******@yahoo.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
The bitmap I'll be printing is an 8.5"X11" form. I don't really need to
display it in the Win Form; I just need to print it with the user
information. So I'm not really sure what you mean by that. Do you know of
any examples on the Web?

Thanks.
"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
VMI,
You can use PrintDocument and just print the bitmap at the
appropriate
location on the form. Make sure to adjust for the printer's dpi settings
though or you will get stretching/shrinking effects on the background.

You
can use DpiX and DpiY properties of the Graphics from the

PrintPageEventArgs
argument to OnPrintPage to get the resolutions.

Ron Allen
"VMI" <vo******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP15.phx.gbl...
>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
> position).
> 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
> resolution.
> Someone suggested using PrintDocument but I'm not sure if it'll be able to > accomplish this.
> Any suggestions are appreciated.
> Thanks.
> BTW, the PDF that contains the form is editable through Acrobat Reader (I > can type into it and print). Maybe that'll help me.
>
>



Nov 16 '05 #4

P: n/a
VMI
Thanks. I works but I don't know how to insert the values into the image.
The values come from the application. Is that possible?
"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl...
VMI,
Sorry I meant page where I said form. I don't know of any examples
offhand on the web but I haven't had any problems printing bitmaps on a page using PrintDocument.
For example the following puts a logo on the page if the logo file
exists on the disk and then sets the x location to just past the right hand side of the logo.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.Xml;
if (System.IO.File.Exists(logoName)) // either specified or stock.
{
Image img = Image.FromFile(logoName);
e.Graphics.DrawImage(img, new PointF(98.0f, 56.5f));
xloc = 1.0f + (img.Width/img.HorizontalResolution) + 0.05f;
}
This puts it at the top left of the page for this form. In your case I
guess that you would just draw the whole thing at 0,0 but be aware that
things outside the printer's hard margins won't be shown.

Ron Allen

"VMI" <vo******@yahoo.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
The bitmap I'll be printing is an 8.5"X11" form. I don't really need to
display it in the Win Form; I just need to print it with the user
information. So I'm not really sure what you mean by that. Do you know of any examples on the Web?

Thanks.
"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
VMI,
You can use PrintDocument and just print the bitmap at the
appropriate
location on the form. Make sure to adjust for the printer's dpi settings though or you will get stretching/shrinking effects on the background.

You
can use DpiX and DpiY properties of the Graphics from the

PrintPageEventArgs
argument to OnPrintPage to get the resolutions.

Ron Allen
"VMI" <vo******@yahoo.com> wrote in message
news:eA**************@TK2MSFTNGP15.phx.gbl...
>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
> position).
> 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
> resolution.
> Someone suggested using PrintDocument but I'm not sure if it'll be

able to
> accomplish this.
> Any suggestions are appreciated.
> Thanks.
> BTW, the PDF that contains the form is editable through Acrobat
Reader (I
> can type into it and print). Maybe that'll help me.
>
>



Nov 16 '05 #5

P: n/a
VMI,
Just draw them at the appropriate location on the page. I use
XmlDocument items to pass my data around. Just put them into an appropriate
XML structure and when you print the page just grab them out of the
structure with SelectSingleNode. Draw them at the appropriate location
using DrawString and the font desired.
You may want to get a copy of Programming Windows in C#/VB.NET by
Petzold as he discusses basic printing there. Or look at some of the
printing examples at www.gotdotnet.com or www.codeproject.com.

Ron Allen
"VMI" <vo******@yahoo.com> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Thanks. I works but I don't know how to insert the values into the image.
The values come from the application. Is that possible?
"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl...
VMI,
Sorry I meant page where I said form. I don't know of any examples
offhand on the web but I haven't had any problems printing bitmaps on a

page
using PrintDocument.
For example the following puts a logo on the page if the logo file
exists on the disk and then sets the x location to just past the right

hand
side of the logo.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.Xml;
if (System.IO.File.Exists(logoName)) // either specified or stock.
{
Image img = Image.FromFile(logoName);
e.Graphics.DrawImage(img, new PointF(98.0f, 56.5f));
xloc = 1.0f + (img.Width/img.HorizontalResolution) + 0.05f;
}
This puts it at the top left of the page for this form. In your case I
guess that you would just draw the whole thing at 0,0 but be aware that
things outside the printer's hard margins won't be shown.

Ron Allen

"VMI" <vo******@yahoo.com> wrote in message
news:u8**************@tk2msftngp13.phx.gbl...
> The bitmap I'll be printing is an 8.5"X11" form. I don't really need
> to
> display it in the Win Form; I just need to print it with the user
> information. So I'm not really sure what you mean by that. Do you know of > any examples on the Web?
>
> Thanks.
>
>
> "Ron Allen" <rallen@_nospam_src-us.com> wrote in message
> news:Oi**************@TK2MSFTNGP10.phx.gbl...
>> VMI,
>> You can use PrintDocument and just print the bitmap at the
>> appropriate
>> location on the form. Make sure to adjust for the printer's dpi settings >> though or you will get stretching/shrinking effects on the background.
> You
>> can use DpiX and DpiY properties of the Graphics from the
> PrintPageEventArgs
>> argument to OnPrintPage to get the resolutions.
>>
>> Ron Allen
>> "VMI" <vo******@yahoo.com> wrote in message
>> news:eA**************@TK2MSFTNGP15.phx.gbl...
>> >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
>> > position).
>> > 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
>> > resolution.
>> > Someone suggested using PrintDocument but I'm not sure if it'll be able > to
>> > accomplish this.
>> > Any suggestions are appreciated.
>> > Thanks.
>> > BTW, the PDF that contains the form is editable through Acrobat Reader > (I
>> > can type into it and print). Maybe that'll help me.
>> >
>> >
>>
>>
>
>



Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.