Render data as an image

05-17-2006, 11:02 AM
Hello everyone,

I haven't posted here in some time and I just ran into a problem (sort of) and remembered how much help I got from this forum!!!

Let me start off by telling you how we currently handle this situation of mine and then I will tell you how we would like to and then hopefully somebody can tell me if it is possible and perhaps - how to get started on it.

Okie dokie - my users use this web application to sort of fill out things they need. At the end of the form they are filling out, there is a finish button and upon finish - the application goes out and gets all that data they just entered that is in the DB and then renders a page contructed of HTML and they can print it out. So, they hit finish and then a new window comes up with a nice printable version of all the stuff they entered - that way they have a paper copy of what they just typed in the app.

We do not want to do that anymore, for certain reasons. What we want to do is, get all that data from the DB and then render an IMAGE displaying the same form that it used to. Does that make sense? This form, currently, that prints out is contructed of html but we don't want to render an html page - we want to just use some sort of control to render an image, identical to what the form used to look like, then after that image pops up in a browser window - in the background - it saves that image to the DB -

I seen some cool ideas of this, sort of (I don't think they are doing exactly what I want to do), here: The demo I was interested in was the one titled: Real-Time Binary Streaming Using Flash, SmartClient or Image. Please help me if you can guys - please please :D



05-17-2006, 11:34 AM
If we're talking VB.NET then you could probably get this to happen using System.Drawing.Graphics. The graphics object supports drawing standard shapes, text, images, and more.

Dim b as new bitmap(1024,768)
Dim g as graphics = graphics.fromimage(b)
Dim f as new font("Arial",8)
Dim x as integer
Dim y as integer
For each s as string in yourdata
PictureBox1.picture = b

Of course you can get a lot fancier than that, and even use the graphics object of a PrintDocument control instead of drawing to a bitmap and showing it in a picturebox.

05-17-2006, 12:19 PM
So, I should probably first draw out what the form needs to look like, i.e. (lines resembling tables, etc..)? and then try to use that drawstring, passing coordinates where needed or something? I am not sure I understand exactly - do you know of a tutorial or something - or perhaps some more detail on how it works or something like that. Thanks.

05-17-2006, 12:43 PM
You could draw the whole table using the graphics objects various methods like DrawLine() and DrawRectangle(), or you could design the table in an imaging program like photoshop, then make a graphics object out of it and draw all your data on top of that. It might look like this:

'load the table image
Dim table as image = image.fromfile("C:\table.jpg")
'get a graphics object using the table image
Dim g as graphics = graphics.fromimage(table)
'make a font
Dim f as new font("Arial",8)
'draw your data strings
'show the final image in a picturebox
PictureBox1.picture = b

Of course the coordinates I provided wouldn't be right since it depends on how you create your table. This can get difficult when you start having to compensate for wrapping text and stuff like that. More about the graphics object can be found here:

05-17-2006, 12:57 PM
Thanks - I understand what you mean/ I'll check out that link as well. I forgot about the need to wrap the text if it is too long - I'll poke around with it because there are many times it does wrap. Thanks for some ideas. I appreciate it.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum