Modifying a PCL Control String

I have a DOS-based program that sends the following two strings to the printer depending on the report being printed:

NORMAL---024  27  38 108  55  46  52  67  27  38  97  54  76  27  40 115  49  51  72  27  38 107  49  49  72
CONDENSE-027  27  38 108  55  46  52  67  27  38  97  53  76  27  40 115  49  54  46  54  72  27  38 107  54  46  56  72

I want the change the regular Courier font that is selected by the string to the Courier Bold font.

(At the time, the programmer did not understand how to invoke anything but the two standard Courier fonts which I believe are Courier 10 (regular) and Courier 16.66 (small).  So, one of the strings also slightly condenses the Courier 10 spacing.  Any help to change that function to a slightly smaller text, which I think is possible, would be helpful as well.

(If you have an idea about the second part, I'll ask it in a separate question.)
LVL 1
Bill GoldenExecutive Managing MemberAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DansDadUKConnect With a Mentor Commented:
Example 1:
<Esc>(0U          Primary Font: Symbol Set (0U = ISO 6: ASCII)
<Esc>(s0p         Primary Font: Spacing: Fixed
       13h        Primary Font: Pitch (13 characters per inch)
       0s         Primary Font: Style (Upright, solid)
       0b         Primary Font: Stroke Weight: Medium
       4099T      Primary Font: Typeface (4099 = Courier)

Open in new window

selects the Courier Regular font with a size of 13 cpi, using the ASCII encoding.

In terms of hexadecimal codes, this is:
1b 28 30 55 1b 28 73 30 70 31 33 68 30 73 30 62 34 30 39 39 54

Open in new window

I'll leave you to convert this to decimal codes.
0
 
Andrej PirmanCommented:
See here:
http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpl02705

Scroll to the bottom and try different codes for Style, Stroke weight and Typeface.

Your string seems to be specific for your printer, so it would help if you tell which printer you have. But you may try changing these values:

NORMAL---024  27  38 108  55  46  52  67  27  38  97  54  76  27  40 115  49  51  72  27  38 107  49  49  72

51 = BOLD

CONDENSE-027  27  38 108  55  46  52  67  27  38  97  53  76  27  40 115  49  54  46  54  72  27  38 107  54  46  56  72

54 = Extra Black
0
 
DansDadUKCommented:
The PCL snippets translate as follows (assuming that I've managed to transcribe your decimal codes correctly):

Decimal codes from NORMAL---024:
27  38 108  55  46  52  67  27  38  97  54  76  27  40  115  49  51  72  27  38 107  49  49  72

Open in new window

PCL:
<Esc>&l7.4C       Vertical Motion Index (7.4/48 inches)
<Esc>&a6L         Left Margin (column 6)
<Esc>(s13H        Primary Font: Pitch (13 characters per inch)
<Esc>&k11H        Horizontal Motion Index (11/120 inches)

Open in new window

Decimal codes from CONDENSE-027:
27  38 108  55  46  52  67  27  38  97  53  76  27  40  115  49  54  46  54  72  27  38 107  54  46  56  72

Open in new window

PCL:
<Esc>&l7.4C       Vertical Motion Index (7.4/48 inches)
<Esc>&a5L         Left Margin (column 5)
<Esc>(s16.6H      Primary Font: Pitch (16.6 characters per inch)
<Esc>&k6.8H       Horizontal Motion Index (6.8/120 inches)

Open in new window

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DansDadUKCommented:
A few comments:

The decimal codes 51 and 54 are not setting the font stroke weight (i.e. they are not selecting Bold or Extra Black).

The Left Margin sequences set the left margin in terms of columns; the width of each column is set to whatever is the current Horizontal Motion Index (HMI) value.

The current HMI value will either be the default value set on the printer itself, or as a result of a previous font select or set HMI sequence in the current session.

The select (primary) font pitch sequences will select a font with the requested size (in terms of character-per-inch), but only if the current font is a fixed-pitch font.
They will also set the current HMI to that pitch value.

The current font value will either be the default value set on the printer itself, or as a result of a previous font select sequence in the current session.

Most LaserJet printers only provide three fixed-pitch fonts: Courier and Letter Gothic (which are both scalable  fonts) and Line Printer (which is a bitmap font, only available in one fixed size).

The set HMI sequences (re-)set the current HMI.

The select (primary) font pitch sequences are only part of a full font selection sequence set; I'll provide examples of full sets in the next post.
0
 
DansDadUKConnect With a Mentor Commented:
Example 2:
<Esc>(0N          Primary Font: Symbol Set (0N = ISO 8859-1 Latin 1)
<Esc>(s0p         Primary Font: Spacing: Fixed
       18h        Primary Font: Pitch (18 characters per inch)
       0s         Primary Font: Style (Upright, solid)
       3b         Primary Font: Stroke Weight: Bold
       4099T      Primary Font: Typeface (4099 = Courier)

Open in new window

selects the Courier Bold font with a size of 18 cpi, using the ISO-8859-1 encoding (a superset of the 7-bit ASCII encoding).

In terms of hexadecimal codes, this is:
1b 28 30 4e 1b 28 73 30 70 31 38 68 30 73 33 62 34 30 39 39 54 

Open in new window

I'll again leave you to convert this to decimal codes.
0
 
Bill GoldenExecutive Managing MemberAuthor Commented:
DansDadUK,

I hate to admit it but I was around when this program was rewritten in the late 80s and sort of remember the teeth gnashing that went into this printer string. Part of the problem was writing a printer string which would work on all the early LaserJets. (Of course this is no longer an issue.)

Secondly, we are using fixed fonts since this program prints financial statements and other columnar documents.

So, if I understand the sequencing order, I would use your example string (modified for stroke weight) in lieu of the 27 40 115 49 51 72 string currently being used?
0
 
DansDadUKCommented:
Yes, although you may want to change the settings (Example 2 selects the Courier Bold font with a size of 18 cpi, using the ISO-8859-1 encoding) if that isn't exactly what you want.

And you may want to move the Left Margin sequence to follow the font select and set HMI sequences, rather than before them - that rather depends on what width you want each of the 'left margin' columns to be.
Or you could instead insert an additional 'set HMI' sequence (with an appropriate value) in front of the 'Left Margin' sequence, in order to define a column-width before setting the margin.
0
 
DansDadUKCommented:
>> ... we are using fixed fonts ...

But if a full font selection sequence (as per my examples) is not included in the sequences sent to the printer, you are relying on the default font set via the printer's front panel menus (or equivalent) - and what's to stop someone changing that?


>> ... Of course this is no longer an issue ...

The cheaper (host-based) LaserJet printers don't understand PCL (or even plain ASCII) so be aware of the capabilities of your target devices.


>> ... I hate to admit it but I was around when this program was rewritten in the late 80s ...

My computer knowledge started in July 1970.
0
 
DansDadUKCommented:
Have you had any success with the modified sequences?
0
 
Bill GoldenExecutive Managing MemberAuthor Commented:
Modifying the control string inside of one of the output files caused the program to die on startup.  So I resorted to modifying the string in the source code and recompiling the program.  Unfortunately someone had failed to transfer the compiler to any of the new workstations and we had to find a backup copy.  I'm hoping the backup contains the latest CMNs files.  (It is a big program, about 55,000 lines in two dozen overlays, written in CB80.   The compiler doesn't want to run on a Windows 7 machine because it needs FCBS and I'm not sure of the proper syntax on a Win7 platform - and if I remember correctly wants to compile only on a FAT32 hard drive.)  I have an older XP machine at home and will setup a D drive for the source code which I have and run the compiler on C which is the environment the compiler want to run in.  
Hoping to try it out this weekend.
0
 
DansDadUKCommented:
Good luck!
0
 
Bill GoldenExecutive Managing MemberAuthor Commented:
Found the compiler and got the FCBS command working.  I finally located the printer selection string in the source code.  

Looks like I'm going to need more help.  

What follows is the source code in the compiler that creates the HEX strings:

^[&l7.4C^[&a6L^[(s10H^[&k11H>

^[&l7.4C^[&a5L^[(s16.6H^[&k6.8H

I am a little confused as to how to proceed!
0
 
Bill GoldenExecutive Managing MemberAuthor Commented:
I had the wrong lines of code.  It should be...

^[&l7.4C^[&a6L^[(s13H^[&k11H>

^[&l7.4C^[&a5L^[(s16.6H^[&k6.8H
0
 
DansDadUKCommented:
On the (reasonable) assumption that ^[ is your editor's method of displaying the non-graphic Escape control-code character (the character with decimal code 27, or hexadecimal 1B), your sequences translate as follows:

<Esc>&l7.4C       Vertical Motion Index (7.4/48 inches)
<Esc>&a6L         Left Margin (column 6)
<Esc>(s10H        Primary Font: Pitch (10 characters per inch)
<Esc>&k11H        Horizontal Motion Index (11/120 inches)
>

Open in new window


<Esc>&l7.4C       Vertical Motion Index (7.4/48 inches)
<Esc>&a5L         Left Margin (column 5)
<Esc>(s16.6H      Primary Font: Pitch (16.6 characters per inch)
<Esc>&k6.8H       Horizontal Motion Index (6.8/120 inches)

Open in new window


<Esc>&l7.4C       Vertical Motion Index (7.4/48 inches)
<Esc>&a6L         Left Margin (column 6)
<Esc>(s13H        Primary Font: Pitch (13 characters per inch)
<Esc>&k11H        Horizontal Motion Index (11/120 inches)
>

Open in new window


<Esc>&l7.4C       Vertical Motion Index (7.4/48 inches)
<Esc>&a5L         Left Margin (column 5)
<Esc>(s16.6H      Primary Font: Pitch (16.6 characters per inch)
<Esc>&k6.8H       Horizontal Motion Index (6.8/120 inches)

Open in new window


The last character (>) in sequences 1 and 3 is a text character.
0
 
DansDadUKCommented:
... and you can do your own decodes (if you have a modern Windows system) using the PRN File Analyse tool in the free PCL Paraphernalia application, available via http://www.pclparaphernalia.eu ; the companion Print Languages tool provides lists of PCL escape sequences if you just want to look up the name of a sequence manually.
0
 
DansDadUKCommented:
... and the following link provides a brief history of the PCL language, and links to the PCL Technical Reference manual, and also to other PCL5 & PJL manuals:

http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpl04568 

Be aware that some of the manuals (in PDF format) are multi-megabyte downloads.
0
 
DansDadUKCommented:
Have you had any success, or do you need more specific advice?

Or are you still making your way through the referenced manuals and tools?
0
 
Bill GoldenExecutive Managing MemberAuthor Commented:
I think I am going to need more specific advice.
0
 
DansDadUKCommented:
>> I think I am going to need more specific advice

Just what is it that you don't understand about the previous advice?


>> ... I want the change the regular Courier font that is selected by the string to the
>> Courier Bold font. ...


So, in your source code, just change the string:

^[&l7.4C^[&a6L^[(s13H^[&k11H

to

^[&l7.4C^[&a6L^[(s0p13h0s3b4099T^[&k11H

I've not included the 'select symbol set' part of the font selection, on the assumption that you're only printing plain ASCII text, but you may need to specify one (to over-ride the default set on the printer, or elsewhere) if you are using extended-ASCII characters, or have problems with currency symbols, etc.
0
 
hdhondtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.