Solved

Textwidth in inches on a printer

Posted on 1997-09-25
2
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month6 days, 19 hours left to enroll

622 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