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

Creating & Printing Graphics

P: n/a

I hope someone can help, this has been driving me mad! I am trying to
generate a graphic on the fly. This is then shown in the browser in a "print
preview" type window. The user can click a "Print" button and all the
graphics are printed. The problem I have is that the text looks distorted.
If you try the example below you will see the problem. This example creates
a graphic, writes some text to it and then saves it to your disk as a full
size image. It is the size it is so that each image becomes a full page when
printed from within IE.

Can anyone help get the text looking ok? Essentially, I need the text to be
printed out prefectly.


Imports System.Drawing
Imports System.Drawing.Printing
Imports System.drawing.Imaging
Imports System.IO

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub DrawPage(ByVal PageNum As Integer)

Dim intW As Integer
Dim intH As Integer

intW = CInt(648)
intH = CInt(978)

Dim objBitMap As New Bitmap(intW, intH)
objBitMap.SetResolution(600, 600)

Dim objGraphics As Graphics
objGraphics = Graphics.FromImage(objBitMap)

objGraphics.PageUnit = GraphicsUnit.Pixel
objGraphics.TextRenderingHint =
objGraphics.SmoothingMode = Drawing2D.SmoothingMode.Default
objGraphics.CompositingQuality = Drawing2D.CompositingQuality.Default

'Set the background color to white

Dim Pen As New Pen(Color.Black, 1)
Dim mFont As New Font("Arial", 14, FontStyle.Regular, GraphicsUnit.Pixel)

objGraphics.DrawRectangle(Pen, 1, 1, (intW) - 2, (intH) - 2)

objGraphics.DrawString("Page " & PageNum & " : Line 1", mFont,
Brushes.Black, 5, 5)
Dim fp As New
FileStream("c:\MDPageImages\ACF24E8D5F884E1E8AD359 254D95057A\Page" & PageNum
& ".png", FileMode.OpenOrCreate)
objBitMap.Save(fp, ImageFormat.Png)

End Sub
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.