473,809 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) 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.SetRe solution(600, 600)

Dim objGraphics As Graphics
objGraphics = Graphics.FromIm age(objBitMap)

objGraphics.Pag eUnit = GraphicsUnit.Pi xel
objGraphics.Tex tRenderingHint =
Text.TextRender ingHint.SingleB itPerPixelGridF it
objGraphics.Smo othingMode = Drawing2D.Smoot hingMode.Defaul t
objGraphics.Com positingQuality = Drawing2D.Compo sitingQuality.D efault

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

Dim Pen As New Pen(Color.Black , 1)
Dim mFont As New Font("Arial", 14, FontStyle.Regul ar, GraphicsUnit.Pi xel)

objGraphics.Dra wRectangle(Pen, 1, 1, (intW) - 2, (intH) - 2)

objGraphics.Dra wString("Page " & PageNum & " : Line 1", mFont,
Brushes.Black, 5, 5)
Dim fp As New
FileStream("c:\ MDPageImages\AC F24E8D5F884E1E8 AD359254D95057A \Page" & PageNum
& ".png", FileMode.OpenOr Create)
objBitMap.Save( fp, ImageFormat.Png )
fp.Close()

End Sub
Nov 18 '05 #1
0 1110

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

Similar topics

5
2165
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 really stuck here (probably the ol' Not seeing the tree cause of the forest thingy). But I just can not get this to work. The following is my Test example code. Just needs a Button1 on a blank Form. Add in PrintDocument1, PrintPreviewDialog1,...
5
10159
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 System.Drawing; using System.Drawing.Printing; using System.IO;
4
9380
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 this differences increases with the increase number of labels. The code is as follwods: Here rdr = OleDbDataReader Font is Times New Roman, 12pt
4
3178
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 system call is too small". I found the following article, that I assume is similar to my problem, which is of little help: http://support.microsoft.com/default.aspx?scid=kb;en-us;822779 Any suggestions?
1
5724
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 of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
7
3042
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 represent a calendar. I want to place text precisely within those boxes on the printed page. I am using Python 2.4 on Windows XP I was in the past able to do this within Visual Basic using its printer object. Visual Basic's printer object uses...
6
3247
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 (much like the current model), but my PrintDocument would have a Pages collection such that each time you need to have an additional page, you would just add another page to the collection and then use the page object for the actual drawing etc. ...
3
3323
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 method some_font.deriveFont(AffineTransform), which would return a new font. (AffineTransform was just a simple 3x3 matrix) I'll be most grateful for the help.
4
2490
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 top of the previous one. So my loop is working, I have the hasmorepages= true set right after each cycle till the loop finishes. Hopefully someone can point out my error. Thanks David DeWitt this part calls the printing code
0
9603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10640
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.