PCL XL, the language of PCL 6, is a binary, object-based language unrelated to the escape sequences of PCL 5. A stream is a series of attributes (typed values, each with an attribute ID) followed by an operator that uses them, like a stack machine. HP’s own reference for it was not available to this page; the tag, attribute and enumeration values below are taken from Artifex’s GhostPDL, which implements PCL XL and marks the additions of protocol classes 2.0 and 3.0.
Stream header
A PCL XL job is entered from PJL (@PJL ENTER LANGUAGE=PCLXL) and
starts with one line of ASCII text, the stream header, ended by LF:
) HP-PCL XL;2;1;Comment, PCL-XL Generator
| Part | Meaning |
|---|---|
| First byte | The binding: ' (0x27) ASCII, ( (0x28) binary with the most significant byte first, ) (0x29) binary with the least significant byte first (the binding tags pxt_beginASCII, pxt_beginBinaryMSB, pxt_beginBinaryLSB). Ghostscript writes ). |
HP-PCL XL | The stream class name. |
;2;1 | Protocol class and revision of the stream, such as 2;1; Ghostscript writes 1;1. The attribute and operator tables mark what classes 2.0 and 3.0 added. |
;… | An optional comment, often the driver’s name. |
After the header come binary tokens up to the end of the job, normally
Esc%-12345X.
Operators
| Tag | Operator | Tag | Operator |
|---|---|---|---|
41 | BeginSession | 42 | EndSession |
43 | BeginPage | 44 | EndPage |
47 | Comment | 48 | OpenDataSource |
49 | CloseDataSource | 4F | BeginFontHeader |
50 | ReadFontHeader | 51 | EndFontHeader |
52 | BeginChar | 53 | ReadChar |
54 | EndChar | 55 | RemoveFont |
56 | SetCharAttributes (2.0) | 5B | BeginStream |
5C | ReadStream | 5D | EndStream |
5E | ExecStream | 5F | RemoveStream (2.0) |
60 | PopGS | 61 | PushGS |
62 | SetClipReplace | 63 | SetBrushSource |
64 | SetCharAngle | 65 | SetCharScale |
66 | SetCharShear | 67 | SetClipIntersect |
68 | SetClipRectangle | 69 | SetClipToPage |
6A | SetColorSpace | 6B | SetCursor |
6C | SetCursorRel | 6D | SetHalftoneMethod |
6E | SetFillMode | 6F | SetFont |
70 | SetLineDash | 71 | SetLineCap |
72 | SetLineJoin | 73 | SetMiterLimit |
74 | SetPageDefaultCTM | 75 | SetPageOrigin |
76 | SetPageRotation | 77 | SetPageScale |
78 | SetPaintTxMode | 79 | SetPenSource |
7A | SetPenWidth | 7B | SetROP |
7C | SetSourceTxMode | 7D | SetCharBoldValue |
7F | SetClipMode | 80 | SetPathToClip |
81 | SetCharSubMode | 84 | CloseSubPath |
85 | NewPath | 86 | PaintPath |
91 | ArcPath | 93 | BezierPath |
95 | BezierRelPath | 96 | Chord |
97 | ChordPath | 98 | Ellipse |
99 | EllipsePath | 9B | LinePath |
9D | LineRelPath | 9E | Pie |
9F | PiePath | A0 | Rectangle |
A1 | RectanglePath | A2 | RoundRectangle |
A3 | RoundRectanglePath | A8 | Text |
A9 | TextPath | B0 | BeginImage |
B1 | ReadImage | B2 | EndImage |
B3 | BeginRastPattern | B4 | ReadRastPattern |
B5 | EndRastPattern | B6 | BeginScan |
B8 | EndScan | B9 | ScanLineRel |
BF | PassThrough (PCL 5 inside PCL XL) |
All other bytes from 0x40 to 0xBF are reserved operators and an error if met.
The attributes of each operator
An operator takes the attribute list that comes before it: each value then its attribute ID. HP’s reference gives each operator’s list as a grammar; “or” marks alternatives, and the optional attributes may be left out. Source: HP’s PCL XL Feature Reference, Protocol Class 2.0 (revision p1.8) and the 2.1 and 3.0 supplements.
| Operator | Required attributes | Optional attributes | What it does |
|---|---|---|---|
BeginSession | Measure, UnitsPerMeasure | ErrorReport | Starts the session: units and error reporting. |
EndSession | Ends the session. | ||
BeginPage | Orientation, MediaSize or CustomMediaSize with CustomMediaSizeUnits | MediaSource, MediaDestination, MediaType, SimplexPageMode or DuplexPageMode with DuplexPageSide | Starts a page. |
EndPage | PageCopies | Ends and prints the page. | |
Comment | CommentData | A comment. | |
OpenDataSource, CloseDataSource | SourceType, DataOrg (open) | Opens and closes the data source. | |
BeginFontHeader | FontName, FontFormat | Starts a soft font download. | |
ReadFontHeader | FontHeaderLength | The header data follows as embedded data. | |
EndFontHeader | Ends the font header. | ||
BeginChar | FontName | Starts one character download. | |
ReadChar | CharCode, CharDataSize | The character data follows. | |
EndChar, RemoveFont | FontName (remove) | Ends a character; removes a soft font. | |
SetCharAttributes | WritingMode | Horizontal or vertical writing (2.0). | |
BeginStream, ReadStream, EndStream, ExecStream, RemoveStream | StreamName; StreamDataLength (read) | User-defined streams, like macros (2.0). | |
PushGS, PopGS | Save and restore the graphics state. | ||
SetClipReplace, SetClipIntersect | ClipRegion | Use the current path as the clip, or intersect it with the clip. | |
SetClipRectangle | ClipRegion, BoundingBox | Clip to a rectangle. | |
SetClipToPage, SetPathToClip, SetPageDefaultCTM | Reset the clip to the page; make the clip a path; reset the coordinate transform. | ||
SetClipMode, SetFillMode | ClipMode, FillMode | Non-zero winding or even-odd. | |
SetBrushSource, SetPenSource | RGBColor or GrayLevel or PrimaryArray with PrimaryDepth or NullBrush (NullPen) or PatternSelectID | PatternOrigin, NewDestinationSize | The paint for fills and strokes. |
SetCharAngle, SetCharScale, SetCharShear, SetCharBoldValue | CharAngle, CharScale, CharShear, CharBoldValue | Text angle, scale, shear and bold. | |
SetCharSubMode | CharSubModeArray | Vertical substitution. | |
SetColorSpace | ColorSpace | PaletteDepth, PaletteData (or the device-independent attributes of 2.0) | Colour space and palette. |
SetCursor, SetCursorRel | Point | Move the cursor, absolutely or relatively. | |
SetHalftoneMethod | DeviceMatrix, or DitherMatrixDataType with DitherMatrixSize and DitherMatrixDepth | DitherOrigin | The halftone. |
SetFont | FontName, CharSize, SymbolSet (or PCLSelectFont) | Selects a font. | |
SetLineDash | LineDashStyle or SolidLine | DashOffset | The dash pattern. |
SetLineCap, SetLineJoin, SetMiterLimit | LineCapStyle, LineJoinStyle, MiterLength | Line ends, joins, miter limit. | |
SetPageOrigin, SetPageRotation, SetPageScale | PageOrigin; PageAngle; PageScale or Measure with UnitsPerMeasure | The page coordinate transform. | |
SetPaintTxMode, SetSourceTxMode, SetROP | TxMode; ROP3 | Transparency and raster operation. | |
SetPenWidth | PenWidth | Stroke width. | |
NewPath, CloseSubPath, PaintPath | Start, close and paint the path. | ||
ArcPath | BoundingBox, StartPoint, EndPoint | ArcDirection | An arc (counter-clockwise by default). |
Chord, ChordPath, Pie, PiePath | BoundingBox, StartPoint, EndPoint | A chord or a pie slice, drawn or added to the path. | |
BezierPath, BezierRelPath | ControlPoint1, ControlPoint2, EndPoint | Cubic Bezier segments, absolute or relative. | |
Ellipse, EllipsePath, Rectangle, RectanglePath | BoundingBox | Draw, or add to the path. | |
RoundRectangle, RoundRectanglePath | BoundingBox, EllipseDimension | A rectangle with elliptical corners. | |
LinePath, LineRelPath | Point, or NumberOfPoints and PointType with the points as embedded data | Line segments, absolute or relative. | |
Text, TextPath | TextData | XSpacingData, YSpacingData | Draw text at the cursor, or add its outline to the path. |
BeginImage | ColorMapping, ColorDepth, SourceWidth, SourceHeight, DestinationSize | Starts an image. | |
ReadImage | StartLine, BlockHeight, CompressMode | PadBytesMultiple, BlockByteLength | A block of rows follows as embedded data. |
EndImage | Ends the image. | ||
BeginRastPattern | ColorMapping, ColorDepth, SourceWidth, SourceHeight, DestinationSize, PatternDefineID, PatternPersistence | Starts a raster pattern. | |
ReadRastPattern, EndRastPattern | StartLine, BlockHeight, CompressMode (read) | PadBytesMultiple, BlockByteLength | Pattern rows; end of the pattern. |
BeginScan, ScanLineRel, EndScan | Scan-line regions; the lines are embedded data. | ||
PassThrough | Passes PCL 5 data through (class 2.0). |
Attribute ranges and data types are in the reference’s appendices F and G, and its Appendix K lists the error codes; those are not written up here.
Attribute IDs
| ID | Attribute | ID | Attribute |
|---|---|---|---|
| 2 | PaletteDepth | 3 | ColorSpace |
| 4 | NullBrush | 5 | NullPen |
| 6 | PaletteData | 8 | PatternSelectID |
| 9 | GrayLevel | 10 | Lightness (2.0) |
| 11 | RGBColor | 12 | PatternOrigin |
| 13 | NewDestinationSize | 14 | PrimaryArray (2.0) |
| 15 | PrimaryDepth (2.0) | 16 | Saturation (2.0) |
| 17 | ColorimetricColorSpace (2.0) | 18 | XYChromaticities (2.0) |
| 19 | WhiteReferencePoint (2.0) | 20 | CRGBMinMax (2.0) |
| 21 | GammaGain (2.0) | 29 | AllObjectTypes (3.0) |
| 30 | TextObjects (3.0) | 31 | VectorObjects (3.0) |
| 32 | RasterObjects (3.0) | 33 | DeviceMatrix |
| 34 | DitherMatrixDataType | 35 | DitherOrigin |
| 36 | MediaDestination | 37 | MediaSize |
| 38 | MediaSource | 39 | MediaType |
| 40 | Orientation | 41 | PageAngle |
| 42 | PageOrigin | 43 | PageScale |
| 44 | ROP3 | 45 | TxMode |
| 47 | CustomMediaSize | 48 | CustomMediaSizeUnits |
| 49 | PageCopies | 50 | DitherMatrixSize |
| 51 | DitherMatrixDepth | 52 | SimplexPageMode |
| 53 | DuplexPageMode | 54 | DuplexPageSide |
| 65 | ArcDirection | 66 | BoundingBox |
| 67 | DashOffset | 68 | EllipseDimension |
| 69 | EndPoint | 70 | FillMode |
| 71 | LineCapStyle | 72 | LineJoinStyle |
| 73 | MiterLength | 74 | LineDashStyle |
| 75 | PenWidth | 76 | Point |
| 77 | NumberOfPoints | 78 | SolidLine |
| 79 | StartPoint | 80 | PointType |
| 81 | ControlPoint1 | 82 | ControlPoint2 |
| 83 | ClipRegion | 84 | ClipMode |
| 98 | ColorDepth | 99 | BlockHeight |
| 100 | ColorMapping | 101 | CompressMode |
| 102 | DestinationBox | 103 | DestinationSize |
| 104 | PatternPersistence | 105 | PatternDefineID |
| 107 | SourceHeight | 108 | SourceWidth |
| 109 | StartLine | 110 | PadBytesMultiple (2.0) |
| 111 | BlockByteLength (2.0) | 115 | NumberOfScanLines |
| 120 | ColorTreatment | 129 | CommentData |
| 130 | DataOrg | 134 | Measure |
| 136 | SourceType | 137 | UnitsPerMeasure |
| 139 | StreamName | 140 | StreamDataLength |
| 141 | PCLSelectFont | 143 | ErrorReport |
| 145 | VUExtension | 146 | VUDataLength |
| 147–152 | VUAttr1–VUAttr6 (vendor-unique) | 161 | CharAngle |
| 162 | CharCode | 163 | CharDataSize |
| 164 | CharScale | 165 | CharShear |
| 166 | CharSize | 167 | FontHeaderLength |
| 168 | FontName | 169 | FontFormat |
| 170 | SymbolSet | 171 | TextData |
| 172 | CharSubModeArray | 173 | WritingMode |
| 175 | XSpacingData | 176 | YSpacingData |
| 177 | CharBoldValue |
Numbers not listed are unassigned in the published protocol classes.
Enumerated values
| Attribute | Values |
|---|---|
ColorSpace | 0 none, 1 Gray, 2 RGB, 6 sRGB |
ColorDepth | 0 1 bit, 1 4 bits, 2 8 bits |
ColorMapping | 0 direct pixel, 1 indexed pixel |
CompressMode | 0 none, 1 RLE, 2 JPEG, 3 delta row |
DataOrg | 0 binary high byte first, 1 binary low byte first |
SourceType | 0 default data source |
Measure | 0 inch, 1 millimetre, 2 tenths of a millimetre |
ErrorReport | 0 none, 1 back channel, 2 error page, 3 both, 4 back channel without stopping, 5 error page without stopping, 6 both without stopping |
Orientation | 0 portrait, 1 landscape, 2 reverse portrait, 3 reverse landscape, 4 default |
MediaSize | 0 Letter, 1 Legal, 2 A4, 3 Executive, 4 Ledger, 5 A3, 6 COM-10 envelope, 7 Monarch envelope, 8 C5 envelope, 9 DL envelope, 10 JIS B4, 11 JIS B5, 12 B5 envelope, 14 Japanese postcard, 15 Japanese double postcard, 16 A5, 17 A6 (class 2.0), 18 JIS B6 (class 2.0); the class 2.0 reference’s Appendix G lists no 13 (GhostPDL names it B5), and later classes add 19 JIS 8K, 20 JIS 16K, 21 JIS Executive, 96 default, and 201–224 newer sizes (B6 JIS, C6 envelope, 8K, 16K, 12×18, 13×19, SRA3, SRA4, 11×14 and others). MediaSize may also be given as a name string. |
MediaSource | 0 default, 1 auto select, 2 manual feed, 3 multi-purpose tray, 4 upper cassette, 5 lower cassette, 6 envelope tray, 7 third cassette; higher numbers device-specific |
MediaDestination | 0 default, 1 face-down bin, 2 face-up bin, 3 job offset bin |
MediaType | given as a name string; 0 default |
SimplexPageMode | 0 front side |
DuplexPageMode | 0 horizontal binding, 1 vertical binding |
DuplexPageSide | 0 front, 1 back |
ArcDirection | 0 clockwise, 1 counter-clockwise |
FillMode, ClipMode | 0 non-zero winding, 1 even-odd |
ClipRegion | 0 interior, 1 exterior |
LineCapStyle | 0 butt, 1 round, 2 square, 3 triangle |
LineJoinStyle | 0 mitre, 1 round, 2 bevel, 3 none |
TxMode | 0 opaque, 1 transparent |
PatternPersistence | 0 temporary, 1 page, 2 session |
DitherMatrixDataType, PointType | 0 ubyte, 1 sbyte, 2 uint16, 3 sint16 |
| Dither matrix | −1 downloaded, 0 device best |
WritingMode | 0 horizontal, 1 vertical |
CharSubModeArray | 0 no substitution, 1 vertical substitution |
ColorTreatment | 0 none, 1 vivid, 2 screen match, 3 text, 4 out of gamut, 5 CIE Lab match 1, 6 CIE Lab match 2 |
| Halftone method (3.0) | 0 high LPI, 1 medium LPI, 2 low LPI; adaptive halftoning 0 off, 1 on |
| Colour trapping (3.0) | 0 off, 1 max, 2 normal, 3 light; neutral axis 0 toner black, 1 process black |
Example
The start of a session, in low-byte-first binding: measure in inches, 600 units per
inch, errors on the back channel, then BeginSession.
C0 00 F8 86 Measure = 0 (inch)
D1 58 02 58 02 F8 89 UnitsPerMeasure = 600, 600
C0 01 F8 8F ErrorReport = 1 (back channel)
41 BeginSession
Attribute types checked, and other rules the viewer applies
The text of Appendix F lost the data-type column of ten attributes; they were read from the page images of the PDF (pages 217 to 219) and the viewer now checks the printed types exactly:
| Attribute | Allowed data types | Other rule |
|---|---|---|
DashOffset (67) | ubyte, uint16, sint16 | range of the data types |
EndPoint (69), StartPoint (79), Point (76) | ubyte_xy, uint16_xy, sint16_xy | two values within the range of the data type |
MiterLength (73) | ubyte, uint16 | range of the data types |
NewDestinationSize (13) | uint16_xy | neither x nor y equal to zero |
NumberOfPoints (77) | ubyte, uint16 | range of the data types |
PenWidth (75) | ubyte, uint16 | zero or more |
RGBColor (11) | real32_array, ubyte_array | three values: 0 to 1.0 if real, or the range of the integer type |
DitherOrigin (35) | ubyte_xy, uint16_xy, sint16_xy | range of the data types |
- SetPathToClip makes the clip the current path. With one clip region the path is that region’s outline. With several regions the path is their intersection (GhostPCL runs the PostScript
clippath). When every region is one polygon and all but one are convex, which covers rectangles, the viewer forms the outline of the intersection and both a fill and a stroke use it. With an exterior region or several concave ones, a fill paints exactly the intersection (the page painted through every region) but a stroke still draws the outlines of the regions. - Character transforms (SetCharAngle, SetCharScale, SetCharShear). The manual says only what the attributes are. GhostPCL (
pcl/pxl/pxfont.candpxgstate.c, labelled as GhostPCL behaviour, not HP’s text) sends each glyph point through the three transforms in order of setting, the most recent first (rotate, shear and scale start in that order and each set moves its transform to the front), then scales by the size with y flipped. The shear matrix is x′ = x + ShearX · y and y′ = y + ShearY · x, and GhostPCL clamps the factors at 16383 (“experiments indicate” in its source, not documented by HP). A bitmap font allows no angle, shear or scale. - Dither matrix and halftone method (
SetHalftoneMethod): the viewer reads them, shows the attributes and does not apply them to the picture. The Feature Reference (section 5.8 and the operator’s Comments) allows exactly this: “some PCL XL implementations may choose to read and ignore the dither matrix data without causing an error condition”, and the user-defined matrix then has no effect. A device that applies it sets a pixel to the lowest intensity when the source intensity is below the matrix cell and to the highest otherwise (a zero cell acts as one), tiles the matrix over the page from DitherOrigin with its bottom row parallel to the bottom edge of the page, and skips two-level sources; the viewer’s anti-aliased drawing does not do this. GhostPCL reads the matrix, pads each row to four bytes, rotates it to the page orientation and rejects DeviceMatrix together with the three matrix attributes as IllegalAttributeCombination. - The ASCII binding. The header byte
'(0x27) is “reserved for the beginning of the ASCII binding” in the tag table, and the header table says that “a PCL XL ASCII binding is used for operators and data”. None of the three documents gives its grammar. The examples in the Feature Reference are printed in a plain notation, one item per line (ubyte e8Bit PaletteDepth,ubyte_array [ 0 255 ] PaletteData,real32_xy 1.75 2.15 WhitePointReference, then the operator’s name,hex_raw* [ 00 00 02 75 … ]for raw bytes,//comments), but the manual never says this is the ASCII binding, nor how a stream in that binding is laid out, so the explorer notes such a stream and does not decode it. GhostPCL’s parser has only the two binary bindings.
Sources
- HP, PCL XL Feature Reference, Protocol Class 2.0 (revision p1.8, January 1998; a copy on a third-party mirror, as HP’s own copy could not be found) – read for the tag tables, the operators’ attribute lists and Appendix G’s enumerations. The Class 2.1 Supplement and the Class 3.0 Supplement were fetched but their additions are taken from GhostPDL’s headers, not checked against them
- GhostPDL gdevpxop.h – every tag byte: binding, operators, data types, attribute and embedded data tags
- GhostPDL gdevpxat.h – attribute IDs, with the 2.0 and 3.0 additions
- GhostPDL gdevpxen.h – enumerated values
- GhostPDL gdevpxut.c – the PJL and stream header the PCL XL driver writes
- GhostPDL
pcl/pxl/pxfont.c,pxgstate.candpxparse.c(single raw files) – the character transform order and shear matrix, the shear clamp, and that the parser knows two binary bindings only; GhostPCL behaviour, not HP’s text - Appendix F pages 217 to 219 of the Feature Reference, rendered to images with PDFKit (
scripts/pcl/render-page.swift) to read the ten attributes whose columns the extracted text scrambled