Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing strings 3

Status
Not open for further replies.

Chinner10

Programmer
Oct 9, 2009
1
GB
I need to print a series of strings using a jet printer, but I have to use a font with equal spacing for the characters or else the formatted string is all over the place and not in the columns which have been formatted. If I could convert these strings to text in Edit or RichEdit, the font could be specified in the Property, but I do not seem to be able to convert the strings.
 
The simplest way to accomplish this is to drop a TMemo on a form. Use the Memo1.Lines.Add() command to add all the strings to the memo. Set the Memo1.Font property as required. Use Memo1.Lines.SaveToFile() to write to disk. Then use ShellExecute(Handle, 'Print', pchar(filename), '', '', SW_SHOWNORMAL) to print the file. You may need to add ShellAPI to your uses clause.

HTH


Roo
Delphi Rules!
 
Are you using the TPrinter class to print to the jet printer? If so, you should be able to set the Font, Size, and location of the text as it appears on the printer canvas and then print to the canvas.
 
For standard text I often just load up a TStringList with what I want printed, and then call
Code:
MyStringList.SaveToFile('\\printserver\sharename');

presuming that the printer you want has been shared on the network.

You can embed HP control codes to do things like bold, or italics, or adjust the font size.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top