Convert PCL to PDF | C#

PCL (Printer Command Language) is a Hewlett-Packard printer language developed to access standard printer features. PCL levels 1 through 5e/5c are command based languages using control sequences that are processed and interpreted in the order they are received. At a consumer level, PCL data streams are generated by a print driver. PCL output can also be easily generated by custom applications.

Currently only PCL5 and older versions are supported

Sets of CommandsSupportExceptionsDescription
Job control commands+Duplex printing modeControl print process: number pf copies, output bin, simplex/duplex printing, left and top offsets etc.
Page control commands+Perforation Skip commandSpecify a size of page, margins, page orientation inter -lines, -character distances etc.
Cursor Positioning Commands+ Specify cursor position and, hence, origins of text, raster or vector images and details.
Font selection commands+
  1. Transparent Print Data Command.
  2. Embedded soft fonts. In current version instead of creating soft font our library selects suitable font from existing "hard" TrueType fonts installed on a target machine.
    Suitability is defined by width/height ratio.
    This feature works only for Bitmap and TrueType fonts and do not guarantee that text printed with soft font will be relevant to the one in a source file.
    Because character codes in soft font can unmatched default ones.
  3. User Defined Symbol Sets.
Allow loading soft (embedded) fonts from PCL file and managing them in memory.
Raster graphics commands+Only black & whiteAllow loading raster images from PCL file to memory, specify raster parameters.
such as width, height, compression type, resolution etc.
Color commands+ Allow coloring for all printable objects.
Print Model commands+ Allow filling text, raster images and rectangular areas with a raster predefined and
user-defined patterns specify transparency mode for patterns and source raster image.
Predefined patterns are hatching, cross-hatch and shading ones.
Rectangle area fill commands+ Allow creation and filling rectangular areas with patterns.
HP-GL/2 Vector Graphics commands+Screened Vector Command (SV), Transparency Mode Command (TR), Transparent Data Command (TD), RO (Rotate Coordinate System), Scalable or Bitmap Fonts Command (SB), Character Slant Command (SL) and Extra Space (ES) are not implemented and DV (Define Variable Text Path) commands are realized in beta version.Allow loading HP-GL/2 vector images from PCL file into memory. Vector image has an origin at lower left corner of the printable area, can be scaled, translated, rotated and clipped.
Vector image can contain text, as labels, and geometric figures such as rectangle, circle, ellipse, line, arc, bezier curve and complex figures composed from the simple ones.
Closed figures including letters of labels can be filled with solid fill or vector pattern.
Pattern can be hatching, cross-hatch, shading, raster used-defined, PCL hatching or cross-hatch and PCL user-defined. PCL patterns are raster. Labels can be individually rotated, scaled, and directed in four directions: up, down, left and right. Left and Right directions involve one-after-another letter arrangement. Up and Down directions involve one-under-another letter arrangement.
Macroses Allow loading a sequence of PCL commands into memory and use this sequence many times, for example, to print page header or set one formatting for a set of pages.
Unicode text Allow printing non ASCII characters. Not implemented due to lack of sample files with
Unicode text
PCL6 (PCL-XL) Realized only in Beta version because of lack in test files. Embedded fonts also are not supported.
JetReady extension is not supported because it is impossible to have JetReady specification.
Binary file format.

Converting a PCL file into PDF format

To allow conversion from PCL to PDF, Aspose.PDF has the class PclLoadOptions which is used to initialize the LoadOptions object. Later on this object is passed as an argument during Document object initialization and it helps the PDF rendering engine to determine the input format of source document.

The following code snippet shows the process of converting a PCL file into PDF format.

public static void ConvertPCLtoPDF()
    PclLoadOptions options = new PclLoadOptions();
    Document pdfDocument= new Document(_dataDir + "demo.pcl", options);
    pdfDocument.Save(_dataDir + "epub_test.pdf");

You can also monitor the detection of errors during the conversion process. To do this, you need to configure PclLoadOptions object: set or unset SupressErrors.

public static void ConvertPCLtoPDFAvdanced()
    PclLoadOptions options = new PclLoadOptions { SupressErrors = true };
    Document pdfDocument= new Document(_dataDir + "demo.pcl", options);
    if (options.Exceptions!=null)
        foreach (var ex in options.Exceptions)
    pdfDocument.Save(_dataDir + "epub_test.pdf");

Known Issues

  1. Origin of text strings and images can be slightly differed from the ones in a sorce PCL file If print direction is not 0°. The same refers to vector images if coordinate system of vector plot is rotated (RO command preceded).
  2. Origin of labels in vector images can be differ from the ones in a sorce PCL file If the labels are influenced by a sequence of commands: Label Origin (LO), Define Variable Text Path (DV), Absolute Direction (DI) or Relative Direction (DR).
  3. A text can be incorrectly read if it must be rendered with Bitmap or TrueType soft (embedded) font, because currently these fonts are only partially supported (See exceptions in “Supported features table”). In this situation text can be correctly read only if character codes in a soft font corresponds to default ones. A style of the read text also can be differed from the one in source PCL file because it is not necessary to set style in soft font header.
  4. If parsed PCL file contains Intellifont or Universal soft fonts exception will be thrown, because Intellifont and Universal font are not supported at all.
  5. If parsed PCL file contains macros commands the result of parsing will strongly differ from the source file, because macros commands are not supported.