Solved

Modifying a PCL Control String

Posted on 2013-02-04
21
430 Views
Last Modified: 2013-03-30
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.)
0
Comment
Question by:Bill Golden
21 Comments
 
LVL 18

Expert Comment

by:Andrej Pirman
Comment Utility
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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
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
 
LVL 16

Accepted Solution

by:
DansDadUK earned 500 total points
Comment Utility
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
 
LVL 16

Assisted Solution

by:DansDadUK
DansDadUK earned 500 total points
Comment Utility
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
 
LVL 1

Author Comment

by:Bill Golden
Comment Utility
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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
>> ... 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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
Have you had any success with the modified sequences?
0
 
LVL 1

Author Comment

by:Bill Golden
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
Good luck!
0
 
LVL 1

Author Comment

by:Bill Golden
Comment Utility
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
 
LVL 1

Author Comment

by:Bill Golden
Comment Utility
I had the wrong lines of code.  It should be...

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

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

Expert Comment

by:DansDadUK
Comment Utility
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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
... 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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
... 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
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
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
 
LVL 1

Author Comment

by:Bill Golden
Comment Utility
I think I am going to need more specific advice.
0
 
LVL 16

Expert Comment

by:DansDadUK
Comment Utility
>> 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
 
LVL 38

Expert Comment

by:Herman D'Hondt
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How to solve seemingly unsolvable printer issues. Users sometimes run into printing issues where all the normal steps do not seem to work. Well the steps below can show users how to take one extra step beyond the normal steps needed to remove old…
You can download the files for this tutorial here (https://www.dropbox.com/s/hgztzt9b60kddc9/DPS%20Demo.zip?dl=0). The .indd file in the InDesign files folder is a finished version of the file; you can start from scratch and work toward this. Also, …
Learn how to automatically add page numbers in your next InDesign project. This can be very helpful in multi-page books and magazines that you are designing. Make sure your Pages window visible.:  In the document you wish to add page numbers to. Act…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now