Windows Develop Bookmark and Share   
 index > Windows Forms General > Print document dynamically
 

Print document dynamically

Hi all,

   Currently i need to develop an application to do the following:

1. Read a data file (in fixed text format) to get the value for each field, for eg,
Name: Ryan Ong
Passport_No: S1235666A
Address_1: Blk 88 Holland Road
Address_2: #12-12 Singapore 123456

2. Base on a xml config file which contains the position (X,Y) of each field to be printed on a A4 paper, using the data above, dynamically position each field value accordingly and send it to a printer for printing.

  Pls kindly advice me how i can achieve the above as i am pretty new to Win Application.

  Thks.

Ryan 



dragon_ballz96  Monday, September 12, 2005 4:24 AM

I would think the easiest way would be to create a Bitmap that contains your document and print it.  If your x and y values are arbitrary, then you're not going to have much fun outputting text to try and match those values for positioning.  It also means you don't have to worry about sorting your text so you print top to bottom, you can just output them all onto a bitmap and then print that.

The other thing is, you need to have an idea of your maximum x and y values before you start, and they may not match your printer page size.  You should scale them, you don't want to output a bitmap in 800*600 and send it to a printer DC with a size of 40000 * 20000 or something.

cgraus  Monday, September 12, 2005 4:44 AM
The program is suppose to pull the data for each field and position it to the designated location (x,y) and then send it to printer for printing on pre-formatted paper (A4 size). By creating a bitmap of such size, any speed problem? Pls advice. Thks.
dragon_ballz96  Tuesday, September 13, 2005 1:36 AM

The main problem would be one of scaling, making sure the end result is high quality. 

Actually, I believe the print method gets passed a graphics object, so it's probably alright to print directly to it.  The only issue I see is with scaling, especially of your font size.  As I say, going to a known size bitmap will mean your image always scales properly.

cgraus  Tuesday, September 13, 2005 2:22 AM

You can use google to search for other answers

Custom Search

More Threads

• cross problem of two box
• Error creating window handle
• Call method in different window
• How to exclude the label contol(s) from the tab sequence?
• ESC key puzzle
• Copying clipboard RTF data to excel sheet and visio
• VS 2005 slow
• Borderless Form -- Right Click Menu of Taskbar
• sample code for programmincally install the "correct version" of .net framework?
• Accessing TitleBar of Windows Form