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

Generating and Image and printing

P: n/a

I am trying to create a "print preview" window for a web site using
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.PageUnit = GraphicsUnit.Millimeter
objGraphics.TextRenderingHint =
objGraphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
objGraphics.InterpolationMode =
objGraphics.CompositingQuality =

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

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)

'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!!

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.