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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A few PCL questions

Status
Not open for further replies.

makaveliuk

Programmer
Dec 1, 2003
46
0
0
GB
I am writing an app to generate cheques from data files, I am new to PCL and it is confusing me a lot!

The things I need to know are:

How do I start/end a page?
How do I download and select a font (I only really need Arial)?
How can I print a multi-line text block?

I have managed to get some output but cannot seem to crack the above problems, all my multi-line text overprints itself on one line, multi-pages all overprint on the same page and everything is in courier and it's driving me mad, any help/advise would be greatly appreciated!
 
1) End a page with either CHR$(12) i.e. FF or
chr$(27);"E" (reset)

Alternatively if using a windows printing program
there is an endpage for sending to the printer.

The Arial font can be closely approximated with
CHR$(27)+"(s4T"

(remember that multiple "commands" can be used in one
string with a CAPITAL letter signifying the end of the
command string)
i.e.
CHR$(27)+"(s0p10h12v0s0b4T"
would set a fixed font (0p) 10CPI (10h) 12 high upright (vs italic etc)->0s, normal (vs bold/light) ->0b and 4T is the typeface (52T should work as well on most printers).

Multi-line text block-- hmm well just print it would be
the first response. If you need to reformat it then make the changes and test it again.

print #15,"Now is the time for all good men"
print #15,"to come to the aid of their country."

If you need to print it at a specific location on the page
(remember you can move around in pcl).
Use
print #15,chr$(27)+"&a#r#H";"Text"
or
print #15,chr$(27)+"&a#v#H";"Text"
where # is the row number when using r, the horizontal or vertial position in 720ths of an inch when using h or v.

(assumes #15 opened to a printer port or as a file to be sent to the printer).

you can also use #C for column number but I discourage that.
Using #C is only closely consistent when using a fixed font
and even then can vary.

 
Thanks for the reply.

That solved most of the problems I had, the only problem I now have is the multi-line text.

I have switched on text wrapping which allows me to print multi-line but I need to print a name and address in a box on a pre-printed sheet, I can position it fine for the first line but each line after resets beack to the far left of the sheet, is there a way to make the next line start at the same position as the first?
 
Certainly.

Use a PCL cursor positioning command immediately before the first character of each line. For example...

<esc>*p300XName
<esc>*p300XAddress
<esc>*p300XCity, State
<esc>*p300XZip

Substitute the 300 with the appropriate value for your needs. By default it is a 300 dpi address space which can be changed to other values with the "user units command", <esc>&u###D .

See the tech ref for allowable values.


Jim Asman
 
or,
<esc>&a#r#Hnamegoeshere
<esc>&a#Haddresshere

assuming you want to print address on next line.

Now there is an alternative though like with the Column
PCL command I discourage it. But you can change the left margin multiple times.
i.e.
<esc>&#L
name
address
city
<esc>&#L
(to reset or set to a different left margin)
as with the column, it works best when the font is fixed.
That is it's most consistant from printer to printer.
 
I'm not sure I typed it in correctly for the left margin
command syntax (it's part of the same group for horizontal/vertical positioning).

S/B
<esc>&a#L
or for basic
print #OuputDevice&,chr$(27);"&a";str$(number);"L"

where OuputDevice& is a number representing a file (stream)
or directly to printer.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top