473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dynamically generating an image then printing

Hi,

I am trying to create a "print preview" window for a web site using asp.net.
I have got a long way down the road to the solution but the problem I have
now is that the text and lines on the printed page are fuzzy.

The following code sample will illustrate the point:

Start of page load code sample
'=========================
Dim objBitmap As New Bitmap(648, 978)
objBitmap.SetResolution(600, 600)

'Declare Graphics objects for painting graphics onto bitmap.
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)

'Set the background color to white
objGraphics.Clear(Color.White)

objGraphics.PageUnit = GraphicsUnit.Millimeter
objGraphics.TextRenderingHint =
Text.TextRenderingHint.AntiAliasGridFit
objGraphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
objGraphics.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
objGraphics.CompositingQuality =
Drawing2D.CompositingQuality.HighQuality

Dim mFont As New Font("Arial", 0.5, FontStyle.Regular,
GraphicsUnit.Millimeter)

Dim sf As StringFormat = New StringFormat
sf.FormatFlags = StringFormatFlags.LineLimit +
StringFormatFlags.FitBlackBox + StringFormatFlags.NoWrap

objGraphics.DrawString("This is some test text. When you print the
bitmap, the text will be distorted.", mFont, Brushes.Black, 5, 5, sf)

objBitmap.Save("c:\MDPageImages\test.bmp", ImageFormat.Bmp)

objGraphics.Dispose()
objBitmap.Dispose()
'====================================
'End of page load sample

Note I have imported:

Imports System.Threading
Imports System.Globalization
Imports System.Drawing
Imports System.drawing.Imaging
Imports System.IO
Imports System.Text

This code sample will create an image to a folder on your local disk (you
may need to grant everyone permission to the folder to get it to work). If
you open the image, it looks fine. When you print the image the text is not
sharp and clear. The font also looks a bit strange.

Can anyone help? this has been driving me mad!!

Mark

Nov 22 '05 #1
7 1731
Mark wrote:
objBitmap.SetResolution(600,Â*600)


That's a pretty low resolution, isn't it ?
Nov 22 '05 #2
Hi,

Whatever I set it to, the results are the same - blurry text!

Mark

"The Man With The Golden Gun" <ro***@moore.bond.007> wrote in message
news:Ac****************@newsread3.news.pas.earthli nk.net...
Mark wrote:
objBitmap.SetResolution(600, 600)


That's a pretty low resolution, isn't it ?

Nov 22 '05 #3

"Mark" <Ma*********@nospam.nospam> wrote in message
news:65**********************************@microsof t.com...
Hi,

I am trying to create a "print preview" window for a web site using asp.net. I have got a long way down the road to the solution but the problem I have
now is that the text and lines on the printed page are fuzzy.

The following code sample will illustrate the point:

Have you tried just sending the information to a memory stream an output it
directly in the browser. For example for a jpeg file you would use the
following:

Response.ClearContent
Response.ContentType = "image/jpeg"
yournewdrawingimage.Save(Response.OutputStream, ImageFormat.Jpeg)
Nov 22 '05 #4
Mark Davison wrote:
Hi,

Whatever I set it to, the results are the same - blurry text!
Ok, so forget about the program for a minute.

At this point, you have a bitmap, and the problem is the fonts look blurry
when printed...but they look sharp crisp and clear when you look at them
through MS-Paint, right ?

And the size of the image that you are printing, is the same size that you
are viewing on screen, right?

When you look at it in MS-Paint, and resize it, do the fonts break up?

Have you thought of resizing your fonts to be the right quality for the size
of image you want to print?

Mark

"The Man With The Golden Gun" <ro***@moore.bond.007> wrote in message
news:Ac****************@newsread3.news.pas.earthli nk.net...
Mark wrote:
objBitmap.SetResolution(600, 600)


That's a pretty low resolution, isn't it ?


--
"You see, in this world there are two types of people, my friend:
those with loaded guns and those who dig. You dig."
-C. Eastwood, G,B&U
Nov 22 '05 #5
Hi,

Thanks for trying to help with this. I am creating the images into a folder
then I am loading them all into a page. It is this page that is getting
printed. As you guessed, when viewing on screen everything looks perfect.

When you say resize the fonts, do you just mean make them bigger i.e. 14pt
instead of 10 or something?

Mark

"The Man With The Golden Gun" <ro***@moore.bond.007> wrote in message
news:9b******************@newsread1.news.pas.earth link.net...
Mark Davison wrote:
Hi,

Whatever I set it to, the results are the same - blurry text!


Ok, so forget about the program for a minute.

At this point, you have a bitmap, and the problem is the fonts look blurry
when printed...but they look sharp crisp and clear when you look at them
through MS-Paint, right ?

And the size of the image that you are printing, is the same size that you
are viewing on screen, right?

When you look at it in MS-Paint, and resize it, do the fonts break up?

Have you thought of resizing your fonts to be the right quality for the
size
of image you want to print?

Mark

"The Man With The Golden Gun" <ro***@moore.bond.007> wrote in message
news:Ac****************@newsread3.news.pas.earthli nk.net...
Mark wrote:

objBitmap.SetResolution(600, 600)

That's a pretty low resolution, isn't it ?


--
"You see, in this world there are two types of people, my friend:
those with loaded guns and those who dig. You dig."
-C. Eastwood, G,B&U

Nov 22 '05 #6
Hi,

That is basically what I am doing. The problem is something abut the image
itself. It displays on-screen fine, but when printed is not clear and crisp.

Mark

"vMike" wrote:

"Mark" <Ma*********@nospam.nospam> wrote in message
news:65**********************************@microsof t.com...
Hi,

I am trying to create a "print preview" window for a web site using

asp.net.
I have got a long way down the road to the solution but the problem I have
now is that the text and lines on the printed page are fuzzy.

The following code sample will illustrate the point:

Have you tried just sending the information to a memory stream an output it
directly in the browser. For example for a jpeg file you would use the
following:

Response.ClearContent
Response.ContentType = "image/jpeg"
yournewdrawingimage.Save(Response.OutputStream, ImageFormat.Jpeg)

Nov 22 '05 #7
I am still no closer to solving this one. Can anyone help?

Mark

"Mark" wrote:
Hi,

I am trying to create a "print preview" window for a web site using asp.net.
I have got a long way down the road to the solution but the problem I have
now is that the text and lines on the printed page are fuzzy.

The following code sample will illustrate the point:

Start of page load code sample
'=========================
Dim objBitmap As New Bitmap(648, 978)
objBitmap.SetResolution(600, 600)

'Declare Graphics objects for painting graphics onto bitmap.
Dim objGraphics As Graphics = Graphics.FromImage(objBitmap)

'Set the background color to white
objGraphics.Clear(Color.White)

objGraphics.PageUnit = GraphicsUnit.Millimeter
objGraphics.TextRenderingHint =
Text.TextRenderingHint.AntiAliasGridFit
objGraphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
objGraphics.InterpolationMode =
Drawing2D.InterpolationMode.HighQualityBicubic
objGraphics.CompositingQuality =
Drawing2D.CompositingQuality.HighQuality

Dim mFont As New Font("Arial", 0.5, FontStyle.Regular,
GraphicsUnit.Millimeter)

Dim sf As StringFormat = New StringFormat
sf.FormatFlags = StringFormatFlags.LineLimit +
StringFormatFlags.FitBlackBox + StringFormatFlags.NoWrap

objGraphics.DrawString("This is some test text. When you print the
bitmap, the text will be distorted.", mFont, Brushes.Black, 5, 5, sf)

objBitmap.Save("c:\MDPageImages\test.bmp", ImageFormat.Bmp)

objGraphics.Dispose()
objBitmap.Dispose()
'====================================
'End of page load sample

Note I have imported:

Imports System.Threading
Imports System.Globalization
Imports System.Drawing
Imports System.drawing.Imaging
Imports System.IO
Imports System.Text

This code sample will create an image to a folder on your local disk (you
may need to grant everyone permission to the folder to get it to work). If
you open the image, it looks fine. When you print the image the text is not
sharp and clear. The font also looks a bit strange.

Can anyone help? this has been driving me mad!!

Mark

Nov 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: C A Upsdell | last post by:
I have a site where I am setting a style dynamically, using the JS statement: obj.style.backgroundImage = 'url(img/bak_page.jpg)'; where 'obj' is either document.getElementById(id), or...
0
by: Mark | last post by:
Hi, I am trying to create a "print preview" window for a web site using asp.net. I have got a long way down the road to the solution but the problem I have now is that the text and lines on the...
7
by: Mark | last post by:
Hi, I am trying to create a "print preview" window for a web site using asp.net. I have got a long way down the road to the solution but the problem I have now is that the text and lines on the...
4
by: CGuy | last post by:
Hi Gurus, I have a rather unique requirements in my ASP.NET application - I need to create image buttons on the fly while rendering a page. The scenario is like this - the user can enter some...
3
by: premier | last post by:
I have a web page that's taking in data from text boxes, drawing a chart to represent the data, and then outputting the chart in PNG format. What I cant figure out how to do, is to output the...
0
by: krish | last post by:
hi, I am dynamically generating Imagebutton (say 5 imagebutton, in loop) . for each imagebutton url , i am dynamically generating image and assigining to it. every thing is ok upto this...
7
by: Ben | last post by:
Hi We are looking for a component that offers that offers the below for Tiff files: Image clean-up (deskew, despeckle) Printing capabilities from VB The ability to add text to image, e.g....
2
by: bizt | last post by:
Hi, Is it possible to obtain the width/ height of an image when that image is dyanically created using a PHP script and passing GET attributes. For example: <img...
3
by: deciacco | last post by:
I'm trying to write a label printing SDI app with a small preview on the main form itself. Every time I run the InvalidatePreview event on the preview control to redraw the preview I get the...
0
by: gnewsgroup | last post by:
In my asp.net 2.0 web application. I create chart images on the fly by getting the data from the database. These chart images all have fixed width, but the height is dynamic depending on the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.