Solved

Textwidth in inches on a printer

Posted on 1997-09-25
2
396 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 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