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

Dynamically generating an image then printing

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
Mark wrote:
objBitmap.SetResolution(600,*600)


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

P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.