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

Printing Question

Hi

I know I can use the GetHeight of the Font object to figure out how many
lines will fit into a page, but how can I find out how many characters will
fit into a line

Thank you,
S. Shulman
Nov 2 '05 #1
2 1078
For a fixed-width font, ex. Courier New, you can get the width of a letter
and check that against your margin area. For a proportional font the only
way I know would be to keep adding words to a string and then check the
width using MeasureString. If you just want to wrap paragraphs into an area
you can use a DrawString overload that takes a rectangle to print in. You
can use a MeasureString overload with the same rectangle to get back the #
of lines generated in the rectangle and the # of characters used from the
string. Then draw the string if everything fits and advance your start
point by the # of lines returned.
All this is a bit oversimplified but it will work for simple text
fitting. For more information you should probably look in
microsoft.public.dotnet.framework.drawing.

Ron Allen
"S Shulman" <sm*******@hotmail.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Hi

I know I can use the GetHeight of the Font object to figure out how many
lines will fit into a page, but how can I find out how many characters
will fit into a line

Thank you,
S. Shulman

Nov 2 '05 #2
Thank you

Shmuel

"Ron Allen" <rallen@_nospam_src-us.com> wrote in message
news:Ok**************@TK2MSFTNGP09.phx.gbl...
For a fixed-width font, ex. Courier New, you can get the width of a letter
and check that against your margin area. For a proportional font the only
way I know would be to keep adding words to a string and then check the
width using MeasureString. If you just want to wrap paragraphs into an
area you can use a DrawString overload that takes a rectangle to print in.
You can use a MeasureString overload with the same rectangle to get back
the # of lines generated in the rectangle and the # of characters used
from the string. Then draw the string if everything fits and advance your
start point by the # of lines returned.
All this is a bit oversimplified but it will work for simple text
fitting. For more information you should probably look in
microsoft.public.dotnet.framework.drawing.

Ron Allen
"S Shulman" <sm*******@hotmail.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Hi

I know I can use the GetHeight of the Font object to figure out how many
lines will fit into a page, but how can I find out how many characters
will fit into a line

Thank you,
S. Shulman


Nov 2 '05 #3

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

Similar topics

2
by: David Isaac | last post by:
I'd like to try personal financial management using Python. I just found PyCheckbook, but it does not support check printing. Is there a Python check printing application kicking around? Thanks,...
8
by: David Isaac | last post by:
"Alan Isaac" <aisaac0@verizon.net> wrote in message news:_A34e.2207$1r6.248@trnddc02... > I'd like to try personal financial management using Python. > I just found PyCheckbook, but it does not...
1
by: Dave | last post by:
Hi, Can anyone direct me to any articles on the best way to give a print option in VB & ASP .net Cheers
9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
2
by: gerb | last post by:
Hello, I realise this is not a pure Javascript question, and that VBscript is probably involved at some point, though not as much as I fear. If you opened this item looking for a pute Javascript...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
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...
10
by: Mtek | last post by:
Hi, I have a web page with some drop downs. Once the user makes his selections the bottom half of the page is populated. When that happens, I want to create a formatted report in a hidden div....
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.