Printing in C#/.NET, scaling on a whole page
I am wondering how to do the following ( couldn't get google to help me here ):
- I got a .jpg file of about 250px*250px in scale..
- I want this image on a DIN-A4 page as often as possible
- I need an "overlay" for every image on the page with a unique code ( lets say a unique barcode for example )
How would i start here? I have really no idea which classes or methods to use for this...
Also it'd be interesting to know which "formats" i can create the documents in...
Thanks for any h开发者_如何学Celp!
Well, you know how big the image is, and how big the paper is, so it's easy to work out how many you can fit on a page.
Then you'll want to create an instance if the Bitmap class from your jpg, then get a Graphics object from the bitmap, call the Graphics object's DrawString method with your text (plus a font, a brush, and a point). Remember to release the Graphics object or, ideally, wrap it in a using
statement.Then, as Henk says, use a PrintDocument to print it - there's an example here of that - and write your images in as required to fill the page using the PrintPageEventArgs' Graphics object.
精彩评论