Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Script to prepend text file w/pcl to fit page

Script to prepend text file w/pcl to fit page

Script to prepend text file w/pcl to fit page

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

RE: Script to prepend text file w/pcl to fit page

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

Assuming that when you wrote:
you really meant:
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:
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:
to control vertical movement (line spacing) where the # value is in units of 1/48 inch.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close