IBM Support

Customizing the INITPRT Tag to Send PCL and PJL Commands to a Laser Printer

Troubleshooting


Problem

This document provides instructions for modifying the printer initialization controls to send PJL commands to the printer when using Host Print Transform (HPT).

Resolving The Problem

This document provides instructions for modifying the printer initialization and printer reset controls sent to the printer when using Host Print Transform (HPT) to print noncollated copies (all copies of page 1, all copies of page 2, and so on). This can be used to simulate multipart forms on a laser or inkjet printer. If collated copies are needed instead, you should change the spooled file attributes to specify the number of copies using the Copies (COPIES) parameter.

This is done by retrieving and modifying a Workstation Customization Table (WSCST) and changing the values in the Initialize Printer (INITPRT) and Reset Printer (RESETPRT) tags.

Note: If these instructions are used to create a workstation customizing object (WSCST), any printer device description or Remote Output Queue (RMTOUTQ) configured to use the WSCST object will print the specified number of copies for every *SCS or *AFPDS printed. If there are cases where only a single copy is needed, the spooled file must be sent to another printer. If using a *LAN printer device description, a Remote Output Queue (RMTOUTQ) or a PC5250 printer session, this could be accomplished by configuring the printer two times - once with the modified WSCST object and once without it.

Caution: These instructions are provided as is. Any assistance with editing the Workstation Customization Table must be done through a consulting agreement.

This document was last updated on 24 October 2013.




Concerning Long Hexadecimal Strings Used in Some Examples

Some of the examples in this document use hexadecimal strings that are longer than will fit on a single line in the WSCST source member.

The trick to specifying long text or hexadecimal strings in your WSCST source code is to put single quotes (or single quotes with an "X" at the end in the case of a hexadecimal string) on each line, but do not use the period (".") to end the tag until the end of your string. Also, when specifying a hexadecimal value, each 2-digit hexadecimal value must remain together on the same line (don't split it in the middle of the hex value).

It is also a good idea to use comments so you know exactly what each byte is supposed to be.

For example:

    :INITPRT
           /* Ec% - 1 2 3 4 5 X @ P J L CrLf */
      DATA = '1B252D31323334355840504A4C0D0A'X
           /* @ P J L   S E T   E C O N O M O D E = O F F CrLf */
             '40504A4C205345542045434F4E4F4D4F44453D4F46460D0A'X
           /* EcE     (Initialize Printer) */
             '1B45'X.





Basic Steps for Creating and Using a Workstation Customization Object

The following are the basic steps for creating and using a Workstation Customization Object (WSCST). Regardless of the particular issues you are attempting to resolve, these steps must always be taken. This information is intended to provide a 'quick start' to creating a WSCST object for users who have at least some familiarity with creating them and with configuring printers.

Note: Additional, in-depth details for creating a WSCST object can be found in the following document:

N1010140: Instructions for Modifying a Workstation Customizing Object (WSCST)

The following are the basic 'quick start' steps.

Step 1: Retrieve the WSCST source code. Type the following command on the operating system command line:

Important Note: Use the Manufacturer type and model (MFRTYPMDL) that is appropriate for your printer. Also, the Source member (in the following example, HP4) is a name that is appropriate to your customizing object. This is what you will be calling your workstation customizing object in Step 3.

RTVWSCST DEVTYPE(*TRANSFORM) MFRTYPMDL(*HP4) SRCMBR(HP4)
         SRCFILE(QGPL/QTXTSRC)

Press the Enter key.

Step 2: Edit the source code by using PDM or SEU:
oTo use PDM, on the operating system command line type the following:

WRKMBRPDM FILE(QGPL/QTXTSRC) MBR(HP4)

Press the Enter key. Select Option 2 to edit.
oTo use SEU, on the operating system command line type the following:

STRSEU SRCFILE(QGPL/QTXTSRC) SRCMBR(HP4)

Press the Enter key.
Make any changes necessary to the WSCST object source code. Refer to the following section Customizing the Initialize Printer (INITPRT) Tag to Set the Number of Copies to make your changes, then save and exit. Continue with Step 3.

Step 3: Create the WSCST object using the CRTWSCST command. On the operating system command line, type the following:

Important Note: Match the SRCMBR name from Step 1 to the WSCST object name that is created in this step.

CRTWSCST WSCST(QGPL/HP4) SRCFILE(QGPL/QTXTSRC)

Press the Enter key.

Step 4: Add the WSCST to the printer configuration by using the Change Device Print command (CHGDEVPRT), the Change Output Queue command (CHGOUTQ), or by changing the PC5250 printer emulation session configuration.
oTo add the WSCST to a device description, on the operating system command line type the following:

CHGDEVPRT DEVD(device_name) TRANSFORM(*YES) MFRTYPMDL(*WSCSTLETTER)
          WSCST(QGPL/HP4)

Press the Enter key.
oTo add the WSCST to a remote output queue description, on the operating system command line type the following:

CHGOUTQ OUTQ(queue_name) TRANSFORM(*YES) MFRTYPMDL(*WSCSTLETTER)
        WSCST(HP4)

Press the Enter key.
oTo add the WSCST to a PC5250 printer emulation session, do the following:

a In the PC5250 printer session, click on Communication > Configure.
b Click on the Setup button.
c In the Configure PC5250 Printer Emulation window, select the box next to Transform Print Data to ASCII on the iSeries and select the Printer Model value of *WSCST.
d In the same window, specify the name of the WSCST in the Customizing Object parameter and the library where it is found in the Library parameter (for example, Customizing Object HP4 and Library QGPL).
e Click OK three times.
f Click File > Save to save the configuration.

Note: If any changes are made to the WSCST object source code after the CRTWSCST command has been issued, it is necessary to issue the CRTWSCST command again. The printer writer must be ended and restarted for the changes to take effect.

Customizing the Initialize Printer (INITPRT) Tag to Set the Number of Copies

The default setting for the Initialize Printer (INITPRT) tag is:

    :INITPRT
     DATA ='1B45'X.


To set the number of noncollated copies desired line spacing, do the following:
1.Append '1B266C' to the DATA string '1B45'.
2.Convert the desired number of copies to the ASCII equivalent, in hexadecimal, and append it to the DATA string as well.
3.Lastly, append '58' to the end of the DATA string.

Example to Hard Code the Number of Copies to 3

1.Append '1B266C' to the DATA string '1B45', which results in:

DATA ='1B451B266C'X.
2.Convert the desired number of copies (3) to the ASCII equivalent, in hexadecimal. Each digit can be converted to ASCII by adding X'30', so the ASCII equivalent of 3 is X'33'. Appending this to the DATA string results in:

DATA ='1B451B266C33'X.
3.Lastly, append '58' to the end of the DATA string. The final result is:

DATA ='1B451B266C3358'X.

Overriding the Number of Copies Specified on a Printer

Occasionally, a printer will be set up to print a certain number of noncollated copies. For example, this can be done on an HP LaserJet 4 printer by changing the COPIES setting in the PRINTING menu. Microsoft Windows applications typically override the setting and print the number of copies specified in the printer driver properties; however, the IBM OS/400 or IBM i5/OS spooled files do not override this setting. This can be resolved by modifying the Initialize Printer (INITPRT) tag to set the number of copies to 1. To do this, change the INITPRT tag to the following:

    :INITPRT
      DATA ='1B451B266C3158'X. /* Force COPIES = 1 on laser printer */

To create the WSCST object and implement it, perform Steps 3 and 4 (above).

Customizing the Initialize Printer (INITPRT) Tag to send @PJL SET ECONOMODE

Many laser printers have a Toner Saver Mode or Econo Mode that can be used to save on the amount of toner used to print spooled files. Spooled files can be successfully printed with either setting, but some consider the output to be too light or too faint when printing with Toner Saver Mode or Econo Mode.

This can typically be controlled when printing from a Windows PC using a setting in the printer driver, though some printers also allow the Toner Saver Mode to be selected in the printer hardware. Host Print Transform (HPT) does not directly control whether or not to use Toner Saver Mode, so if the printer hardware defaults to use Toner Saver Mode then printing from the IBM i System will typically print in Toner Saver Mode even if user choose to turn off Toner Saver Mode in their Windows printer driver.

Windows printer drivers typically control this setting by sending a '@PJL SET ECONOMODE=OFF' or a '@PJL SET ECONOMODE=ON' command to the printer. However, this may not be universal, so it would be best to use the Windows printer driver for your specific model of printer but print to FILE: and the view the resulting file using MS WordPad to see if they are sending the following PJL command:

<Esc>-12345X
@PJL
@PJL SET ECONOMODE=OFF


If that is the command used, then this same command can be sent from the IBM i System by modifying the Initialize Printer (INITPRT) tag to send this same ASCII text string (in hexadecimal). To do this, change the INITPRT tag to the following:

    :INITPRT
           /* Ec% - 1 2 3 4 5 X @ P J L CrLf */
      DATA = '1B252D31323334355840504A4C0D0A'X
           /* @ P J L   S E T   E C O N O M O D E = O F F CrLf */
             '40504A4C205345542045434F4E4F4D4F44453D4F46460D0A'X
           /* EcE     (Initialize Printer) */
             '1B45'X.

Note: If you instead want to always use Toner Saver Mode or Econo Mode when printing from the IBM i System, you can change the INITPRT tag to send '@PJL SET ECONOMODE=ON' to the printer instead. For example:

    :INITPRT
           /* Ec% - 1 2 3 4 5 X @ P J L CrLf */
      DATA = '1B252D31323334355840504A4C0D0A'X
           /* @ P J L   S E T   E C O N O M O D E = O N CrLf */
             '40504A4C205345542045434F4E4F4D4F44453D4F4E0D0A'X
           /* EcE     (Initialize Printer) */
             '1B45'X.

To create the WSCST object and implement it, perform Steps 3 and 4 (above).

Customizing the INITPRT Tag to send @PJL SET USERNAME and @PJL SET JOBNAME

Windows printer drivers typically send a user name and job name to an ASCII laser printer by sending '@PJL SET USERNAME' and '@PJL SET JOBNAME' commands to the printer. In some cases, this information is displayed on the printer control panel or logged to the printer history as the spooled file is being printed. The USERNAME and JOBNAME commands may not be universal, so it would be best to use the Windows printer driver for your specific model of printer but print to FILE: and the view the resulting file using MS WordPad to see if they are sending the '@PJL SET USERNAME' and '@PJL SET JOBNAME' commands.

Host Print Transform (HPT) does not directly control the setting of the user name and job name. Therefore, there is no way to have a unique user name and job name sent for each spooled file. However, it can be setup to hard-code values that will identify that printing is coming from the IBM i System. For example:

<Esc>-12345X
@PJL
@PJL SET USERNAME = "QSPLJOB"
@PJL SET JOBNAME = "IBM i Print"


These specific commands can be sent to the printer by modifying the Initialize Printer (INITPRT) tag. For example:

    :INITPRT
           /* Ec% - 1 2 3 4 5 X @ P J L CrLf */
      DATA = '1B252D31323334355840504A4C0D0A'X
           /* @ P J L   S E T   U S E R N A M E   =    */
             '40504A4C2053455420555345524E414D45203D20'X
           /* " Q S P L J O B " CrLf */
             '225153504C4A4F42220D0A'X
           /* @ P J L   S E T   J O B N A M E   =    */
             '40504A4C20534554204A4F424E414D45203D20'X
           /* " I B M   i   P r i n t " CrLf */
             '2249424D2069205072696E74220D0A'X
           /* EcE     (Initialize Printer) */
             '1B45'X.

To create the WSCST object and implement it, perform Steps 3 and 4 (above).

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]

Historical Number

632018616

Document Information

Modified date:
18 December 2019

UID

nas8N1011016