473,327 Members | 1,936 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,327 software developers and data experts.

PrintDocument and Wrapping

In the small test class below I have roughed out a wrapping of the string
using drawstring and measurestring. Note that without the to Math.Ceiling
uses that the drawstring still produces ellipsis. Is there anything I'm
missing here? I attempted to use a class from Duncan Mackenzie which seemed
to be doing the same thing as below but wrapping did not work. the text was
jumbled onto one line. Duncan changed the units to inches should I do the
same?

Public Class TestPrintDocument
Inherits System.Drawing.Printing.PrintDocument
Protected Overrides Sub OnPrintPage(ByVal e As
System.Drawing.Printing.PrintPageEventArgs)
Dim h As Integer = 50
Dim w As Integer = 100
Dim rect As New RectangleF(50, 50, w, h)
Dim textof As String = "test the wrap of a string for print. does it wrap?"
Dim tfont As New Font("Arial", 10)
Dim sf As New StringFormat(StringFormatFlags.LineLimit)
Dim tsize As New SizeF(e.Graphics.MeasureString(textof, tfont))
Dim ratio As Single = Math.Ceiling(tsize.Width / w)
If ratio > 1 Then
rect.Height = (ratio) * Math.Ceiling(tsize.Height)
End If
sf.Alignment = StringAlignment.Near
sf.Trimming = StringTrimming.EllipsisCharacter
Dim i As Integer
For i = 0 To 2
e.Graphics.DrawString(textof, tfont, Brushes.Black, rect, sf)
rect.Y += rect.Height
Next
End Sub

End Class
Nov 20 '05 #1
0 964

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

Similar topics

3
by: Palli Olafs | last post by:
Hi Is it possible to save the PrintDocument as file without using a printer?
3
by: Randy | last post by:
Hello, I'm trying to print a dataGrid using PrintDocument control. My datagrid has about 23 columns so it is fairly wide. When I use the PrintControl, it prints only the part of the dataGrid that...
1
by: Frank Rizzo | last post by:
Hello, I have an OCX control on my WinForm (don't ask, i have to use it) and it generally works well. One of the methods of the OCX prints to an hDC (device context handle for history buffs). ...
0
by: active | last post by:
Dim mPD As PrintDocument Dim mPrinternameSaved As PrintDocument Public WriteOnly Property PrintDocument() As PrintDocument Set(ByVal value As PrintDocument) mPD = value mPrinternameSaved = mPD...
2
by: Steve | last post by:
I'm trying real hard to set the printer resolution for a PrintDocument. It appears that the printer is already set to 300 x 300 dpi, which is JUST what I want. But the Margins and PrintableArea...
2
by: bp | last post by:
Hi, I try to use my own PreviewDialog with a PrinPreviewControl, to preview a document of type MyPrintDocument, and I want to implement the PrintRange functionnality (print some pages between 2...
1
by: kig25 | last post by:
Hello, When using the VB.NET PrintDocument class, I seem to be encountering an issue where the sub pd_PrintPage handles PrintDocument.PrintPage (upon continuing if HasMorePages = true) will...
1
by: chankey | last post by:
I have code that is able to print using the PrintDocument class, PrintPage event and the Graphics.DrawString method. It is on the slow side though. Does anyone have an ideas on how to speed up...
16
by: raylopez99 | last post by:
I am running out of printing paper trying to debug this...it has to be trivial, but I cannot figure it out--can you? Why am I not printing text, but just the initial string "howdy"? On the...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.