Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Textwidth in inches on a printer

Posted on 1997-09-25
2
Medium Priority
?
405 Views
Last Modified: 2010-04-04
I have tries the following code:
    Printer.BeginDoc;
    Printer.Canvas.Font.Assign(Font);
    t:=Printer.Canvas.TextWidth(s);  { s is a string }
    PixelsPrInch:=GetDeviceCaps(Printer.Handle,LOGPIXELSX);     WidthPrint:=t/PixelsPrInch;
    Printer.Abort;
    Printer.EndDoc;

The problem is that the code sends a small file (1kb) to the printer. The file is newer printed, but remans in the printer queue. Since i use this many time in the programme, the printer queue is filled up and generates an error.

I have tried not using the EndDoc method, but that just gives a "Printer in use" error when the procedure is called next time.
0
Comment
Question by:kvj
2 Comments
 
LVL 1

Accepted Solution

by:
jturpin earned 360 total points
ID: 1346287

Don't use
   Printer.BeginDoc;
and
   Printer.Abort;
   Printer.EndDoc;

if you just say:
   Printer.Canvas.Font.Assign(Font);
   t:=Printer.Canvas.TextWidth(s); { s is a string }
   PixelsPrInch:=GetDeviceCaps(Printer.Handle,LOGPIXELSX);
   WidthPrint:=t/PixelsPrInch;

you will get what you want.

John.

0
 

Author Comment

by:kvj
ID: 1346288
This works, but it is also runs very slow. Any ideas on how to speed it up ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question