My IPeople

Community discussion for IPeople products and services
Welcome to My IPeople Sign in | Help
Home Blogs Forums

Using PCL Codes for Advanced Formatting

  •  08-17-2006, 5:29 PM

    Using PCL Codes for Advanced Formatting

    What is PCL?
    PCL, or Printer Command Language, is an HP standard that works with most printers.  NPR only gives you limited control over the format of reports.  With PCL, you can do many things that are not possible with basic NPR commands.  However, using PCL can quickly make a report complicated and difficult to read, so it should be used sparingly.

    How do I use PCL in reports?
    PCL codes all begin with the escape character, which is D(27) in NPR.   There are too many PCL commands to list here, but many good references exist online.  A personal favorite of mine can be found at http://www.nefec.org/UPM/ccPCLfrm.htm.  In order to send data directly to the output device, you use ^!.  Bear in mind, though, that if you choose an output other than a PCL compatible printer, the PCL codes will appear as plain text instead of performing the expected operation.

    Putting it all together, let's go over several examples of commonly used PCL codes.  In this case, we will set the printer to duplex mode.  To do this, the following footnote is used:

    AL PRINT D(27)_"&l1S"^!

    Starting at the left, AL PRINT instructs Meditech to execute this code before the report is printed. 
    D(27)_ instructs Meditech to begin a string with the escape character.  "&l1S" is the PCL code which sets the printer to duplex mode.  Finally, ^! sends the PCL code to the printer.

    At the end of a report using duplexing, you'll want to include the following footnote as well: 

    AL CLOSE.UP D(27)_"&l0S"^!

    This looks a lot like the previous line of code, but it is run after the report has printed and is used to return the printer to single-sided mode.

    As another example, suppose we wanted to set the report to always print three copies.  We could also use a PCL command in a footnote in order to accomplish this, as shown below:

    AL PRINT D(27)_"&l3X"^!

    Here, everything is the same, with the exception that the PCL code allows you to specify a number of copies.  In &l3X, the "3" can be changed to any value from 1 to 99.

    PCL codes can be used in macros, line attributes, and computed fields as well, but most page formatting PCL codes need to be sent to the printer before anything else.  So, for example, if a line check halfway through the report sent the code to begin duplex mode, the report would still only print in simplex.

    Summary
    PCL codes allow you to escape some of Meditech's limitations.  However, given the difficult nature of debugging NPR reports and the complexity of PCL formatting, it is best to only use them when absolutely necessary.

    Filed under: ,
View Complete Thread
Powered by Community Server, by Telligent Systems