PCL language/escape codes (selecting paper source when printing) from HPUX

Posted on 2011-10-10
Last Modified: 2012-05-12

We have recently procured a Brother HL-6050 printer.

In UNIX (HP-UX) we have a program that requires a single program output to be printed on A5 (optional tray) whereas the default be A4 (tray 1).

If I place the following line in the header of the output print header of the program,

disp "\033&l5H\c"

Then the program prints from the optional tray (currently with A4 in it).

So far so good....

Now I replace the A4 paper in the optional tray with A5 paper and run exactly the same program. Now instead of using the optional tray as the source it starts to use tray 1 again (the wrong tray).

Any ideas much appreciated!
Question by:johnsit
    LVL 20

    Assisted Solution

    Possibly the printer believes A4 is needed (or is told by the driver/app) and therefore the printer switches to a tray that has that size.

    Try sending "\033&l4A\c" (Specify A5) instead of (or as well as) the tray selection string

    LVL 16

    Expert Comment

    >> Try sending "\033&l4A\c" (Specify A5) instead of (or as well as) the tray selection string

    I support tfewster in his/her supposition that specifying a PaperSize of A5 (as well as the tray identifier) is probably what is required.

    But I don't think that the suggested code is correct.

    The 'select PaperSize' escape sequence has the generic form:



    <esc> represents the escape character (the character with decimal code 27, or hexadecimal 1B, or octal 033).

    the character after the & (ampersand) is a lower-case L (not a digit 1)

    and where the standard # values include:
    #=2 for Letter
    #=26 for A4
    #=25 for A5

    The \033 is the *n*x method of specifying (in octal) the code-point value of the Escape character.
    ... but I've no idea what the \c means; the PCL5 escape sequence is complete at the 'A' termination character.
    LVL 16

    Expert Comment

    I've found the answer to my own little question about what \c signifies:

    "UNIX Korn shells use the \c escape character to signal continuation (no automatic line break)"

    So it presumably stops the 'disp' command from adding LineFeed (0x0a) and/or CarriageReturn (0x0d) characters to the output string.
    LVL 16

    Expert Comment

    ... and if you want to experiment with different combinations of PaperSize, PaperType and TrayIdentifier PCL5 sequences, use the 'TrayMap' tool in the PCLParaphernalia application (see ).

    It won't run on HP-UX; it's a .NET 4.0 application, so would require a modern Windows system to run it on.

    Author Comment

    Thanks for all the great help so far!

    Im a bit new to unix and PCL, so to clarify, what would I use for the complete code on one line using the following codes?


    Would it be

    disp "\033&l5H\033&l4A\033(s12.5h\c"?

    Thanks again.
    LVL 16

    Accepted Solution

    There are several errors in your *n*x representation of the required PCL5 compound parameterised escape sequence.

    - As mentioned before, the standard # value for a PaperSize of A5 is 25, not 4; Brother documentation mentions 25, but not 4 (I don't think that 4 is assigned to any size).
    So the first sequence would be (in *n*x notation) \033&l25A

    - The third sequence is a partial font selection sequence; but the termination character should be upper-case H (not lower-case h) as it is not a term within a 'combination' sequence.
    So the sequence would be (in *n*x notation) \033(s12.5H

    ... and as it is only a PARTIAL font selection, it will only have the desired effect (to select a pitch of 12.5 characters-per-inch) if the currently-selected font is a fixed-pitch font (like Courier or Letter Gothic).

    So your compound string would be:

    disp "\033&l25A\033&l5H\033(s12.5H\c"

    or (taking advantage of PCL5 'combination' sequences - those with the same 'root'):

    disp "\033&l25a5H\033(s12.5H\c"

    ... and the following should select Courier 12.5 cpi Regular, using the ISO 8859/1 character set, using a full font selection sequence, as well as the paper/tray selections:

    disp "\033&l25a5H\033(0N\033(s0p12.5h0s0b4099T\c"
    LVL 16

    Expert Comment

    ... and here is an analysis of the compound statement:

    <Esc>&l25a        Page Size: A5
           5H         Paper Source: id 5 is Printer Dependent
    <Esc>(0N          Primary Font: Symbol Set (identifier = 0N)
    <Esc>(s0p         Primary Font: Spacing: Fixed
           12.5h      Primary Font: Pitch (12.5 characters per inch)
           0s         Primary Font: Style (Upright, solid)
           0b         Primary Font: Stroke Weight: Medium
           4099T      Primary Font: Typeface (identifier = 4099)

    Open in new window

    LVL 16

    Expert Comment

    ... but if your application/driver already inserts a 'Set Page Size' sequence (for, say, 'A4') in the output print stream, if you select 'A5' by adding the required sequence 'in the header', then you'll possibly get a blank A5 page (but maybe not, depending on what else is in the stream)) followed by the data on A4 page(s).

    Author Comment

    Thanks very much DansDad,

    Probably one of the best and complete answers Ive received!

    I have awarded 400 to yourself and 100 to tfewster for the initial tip, hope this OK.

    Very much appreciated.

    Author Closing Comment


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Some time ago I was asked to set up a web portal PC to put at our entrance. When customers arrive, they could see a webpage 'promoting' our company. So I tried to set up a windows 7 PC as a kiosk PC.......... I will spare you all the annoyances I…
    Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    746 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

    14 Experts available now in Live!

    Get 1:1 Help Now