Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Textwidth in inches on a printer

Posted on 1997-09-25
2
Medium Priority
?
402 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 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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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