Solved

Textwidth in inches on a printer

Posted on 1997-09-25
2
390 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 120 total points
Comment Utility

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
Comment Utility
This works, but it is also runs very slow. Any ideas on how to speed it up ?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now