473,398 Members | 2,188 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,398 software developers and data experts.

Creating & Printing Graphics

Hi,

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.

Regards,

Mark
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
DrawPage(1)
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 =
Text.TextRenderingHint.SingleBitPerPixelGridFit
objGraphics.SmoothingMode = Drawing2D.SmoothingMode.Default
objGraphics.CompositingQuality = Drawing2D.CompositingQuality.Default

'Set the background color to white
objGraphics.Clear(Color.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)
fp.Close()

End Sub
Nov 18 '05 #1
0 1088

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

Similar topics

5
by: Mr. B | last post by:
This is driving me NUTZ!!! I've been screwing around on this for a week now. And I have tried to find examples similar to what I have (nada). Got lots of streaming a TXT file... bah! I am...
5
by: Patrick De Ridder | last post by:
How can I turn what I want to print 90 degrees using the logic below? Please tell me the code with which to make the modification. Many thanks, Patrick. using System.ComponentModel; using...
4
by: Arif | last post by:
I C# code prints very slow as compared to a third party barcode printing software. That software prints approximately 10 labels in 2 seconds while my C# code prints 10 labels in 5 to 6 seconds. And...
4
by: Rob T | last post by:
I have a small VB program that has a printing module...very simple....and works great. However, If I try to print to a generic printer, I get the following error: "The data area passed to a...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
7
by: Michael Galvin | last post by:
I am trying to use Python to send to the printer a calender filled with a mix of text and simple graphics. I want to draw on the printed page something like a table with 6 rows and 7 columns to...
6
by: Chris Dunaway | last post by:
The method for printing documents in .Net can be confusing, especially for newer users. I would like to create a way to simplify this process. My idea would be implemented using a PrintDocument...
3
by: k | last post by:
Hi, I'm trying to migrate from Java to C# and have encountered a problem. I can't seem to find a way to create (ultra)condensed fonts for later use in a program. In Java I had a really nice...
4
by: DeWittds | last post by:
I have asked before and got little responce, So I try and try again. The code below prints the data in the same place but does not advance the page. I can see the lblnumber change but print in...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.