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

Script to prepend text file w/pcl to fit page

Status
Not open for further replies.

richa60

Programmer
Jan 3, 2004
4
0
0
US
Anybody have a script (maybe perl?) that you can pass a text file to, and it will determine the length of the longest line in the file, then pre-pend the file with PCL code that will size and orient the text so that it will best fit a letter sized page in a non-proportional font?

For example,
if $longestline < 80 print portrait, 10cpi
if $longestline < 96 print portrait, 12cpi
if $longestline < 120 print portrait, 16 cpi
...
if $longestline < x print landscape, 12cpi
if $longestline < y print landscape, 16cpi
...
Maybe even have a legal size page option if $longestline is very long.

I have something that works with 10, 12, & 16 cpi using "[esc]&_S" but am stuck understanding how to get a more precise fit with other spacings such as 11cpi, 13cpi, etc.

Thank you,
Rich Alexander
 
I don't have a script, but I can offer some advice on use of PCL sequences.

Assuming that when you wrote:
[esc]&_S
you really meant:
[esc]&k#S
where [esc] represents the escape character (hexadecimal 1b or decimal 27).

This is the old Character Spacing PCL sequence which is considered to be obsolete (although it probably still works on most modern PCL printers); in this sequence, a # value of 0 indicates Pica (10cpi), whilst a value of 1 indicates Condensed (16.66cpi).

The modern equivalent is to make use of font selection sequences; for example:
[esc](19U[esc](s0p10.00h0s0b4099T
would (on modern HP LaserJets and clones) select a fixed-pitch font (0p), using the Courier typeface (4099T) in upright style (0s), normal weight (0b), at size 10 characters per inch (10.00h). For different sizes just use a different value for this part of the sequence. You can print off PCL Typeface lists (from most modern printers) which show this sort of representation for the fonts resident on the device.

The first part of the sequence indicates the required character (symbol) set; 19U is the standard Windows ANSI set; 0N is the standard ISO8859/1 set.

You would probably also need to consider use of the sequence:
[esc]&l#C
to control vertical movement (line spacing) where the # value is in units of 1/48 inch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top