How to Customize Margins on IBM 4039 Printer


About this document

About this document

This document describes how to customize an AIX PCL virtual printer to print closer to the margins than the defined margins set by the AIX virtual printer. The discussion revolves around the Lexmark 4039 printer, but this method applies to all PCL laser printers with only minor modifications. Both a simplified customization method and a more complex example are given.

The information in this document applies to all levels of AIX.

This solution is for PCL (text) printing only.


The virtual printers in AIX support only the default page sizes which give margins on letter paper of 1/2 inch on the top and bottom. The left and right margins are about 1/2 inch. The virtual printer does not have commands for setting the top and bottom margin smaller than this. If you want the top and bottom margins to be larger than 1/2 inch, this can easily be done by using the qprt -t flag with the number of lines to increase the top margin, and the qprt -b flag for the bottom margin. AIX will simply add line feeds to fill the page.

To have the printer print closer to the edge of the page you will need to send the printer one or more of the commands shown in the table below.

PCL Margin Commands

Command PCL Command Description
Top Margin ESC&l#E Sets Top Margin based on current VMI Vertical Motion Index The default top and bottom margins are 12.7 mm (1/2 in.) A value of 0 will print in the top unprintable line. A value of 1 ESC&l1E will give a margin of about 3/16 of an inch. To adjust margins finer, you will also need to send a new VMI.
Text Length ESC&l#F The number of lines should be no greater than the logical page length minus the top margin. The actual bottom margin will be determined by the VMI (lines per inch), the top margin, and this value.
Left Margin ESC&a#L The left margin command sets the column which forms the left margin from the measured left edge of the logical page, based on the space width of the HMI Horizontal Motion Index. ESC&a6L sets the left margin at column 6, and printing betgins at column 7.
Right Margin ESC&a#M The right margin command sets the column which forms the right margin, measured from the left edge of the logical page, based on the current HMI. For example ESC&a63M sets the right margin at column 63.
Clear Horizontal Margins ESC9 Sets the left and right margins to the default settings. The text is bounded by the logical page.
Set HMI ESC&k#H Set the Horizontal Motion Index to determine the column width. The parameter is an increment equal to 1/120 inch and is valid to 4 decimal places. ESC&k10H sets 1/12 in. column width.
Set VMI ESC&l#C Set the Vertical Motion Index to determine the space between lines. The parameter is an increent equal to 1/48 inch and is valid to 4 decimal places. ESC&l6C sets 1/8 in. VMI.
Set Lines Space ESC&l#D Alternative Method for lines per inch. This sets the lines per inch and valid values are 1, 2, 3, 4, 5, 8, 12, 16, 24, 48 (lines/inch).


Because this is not really supported by the virtual printer, the method discussed here replaces all the virtual printer commands and do no formatting on the data. The following commands will print a page 64 lines long by 80 characters wide at 10 characters per inch. This does assume you have created a virtual printer.

Option 1 - Minimal Config

  1. lsvirprt - command to edit virtual printer.

  2. Select the virtual printer.

  3. d=p - This will turn off formatting

  4. cr= - Turn of printer reset commands. Doesn't matter.

  5. ci=%IpU%IpL%IeR%IeP\33&l1E\33&l64F\33&k2G


This should all fit on the page.

Option 2 - Advanced Config

Starting with a new virtual printer this configuration will allow many of the flags to still function.

  1. lsvirprt

  2. d=p - turn off formatting

  3. ct=\33&k2G - Tell printer to add carriage returns.

  4. ci~v - Edit ci with vi like editor
    Command To Initialize the Printer
    ci = %I[pU,pL,pU,pR,pL]%?%G_j%{1}%=%t%I[eP,c1,eT,eS,eO,ct,eF,eu,es,eC]%;
     %IpU          INCLUDE: (Reset command)
     %IpL          INCLUDE: (Command to set printer language)
     %IpU          INCLUDE: (Reset command)
     %IpR          INCLUDE: (Command to set printer resolution )
     %IpL          INCLUDE: (Command to set printer language)
         %G_j      PUSH: (INITIALIZE printer?)
         %{1}      PUSH: (Integer Constant 1)
         %=        PUSH: (pop2 = pop1 ?)
         %IeP      INCLUDE: (Select pitch - default is 10)
         %Ic1      INCLUDE: (Select the Roman-8 symbol set)
         %IeT      INCLUDE: (Set Typeface/style/weight)
         %IeS      INCLUDE: (Set Duplex/Simplex Mode)
         %IeO      INCLUDE: (Specify the page orientation)
         %Ict      INCLUDE: (Set line termination mode)
         %IeF      INCLUDE: (Select font if specified)
         %Ieu      INCLUDE: (Generate the paper source escape sequence)
         %Ies      INCLUDE: (Set Page Size)
         %IeC      INCLUDE: (Set the vertical line spacing (VMI))
  5. Add at the very end:
  6. :wq to save changes.

  7. t=1 to set top margin to 1

  8. l=70 to set lines per page to 70 or desired value

  9. eC~v
    Edit this value to show:  You can play with the 505000 to adjust
    the bottom margin.
    Set the vertical line spacing (VMI)
    eC = \33&l%{505000}%Gwn%/%Pq%gq%{100}%/%d.%gq%{100}%m%2dC
     %{505000}     PUSH: (Integer Constant 500000)
     %Gwn          PUSH: (Effective Line Density (lines per inch x 100))
     %/            PUSH: (pop2 / pop1)
     %Pq           POP -> Internal Variable q
     %gq           PUSH: (Internal Variable q)
     %{100}        PUSH: (Integer Constant 100)
     %/            PUSH: (pop2 / pop1)
     %d            POP -> ASCII String -> OUTPUT
     %gq           PUSH: (Internal Variable q)
     %{100}        PUSH: (Integer Constant 100)
     %m            PUSH: (Modulus of (pop2 / pop1))
     %2d           POP -> ASCII String (2 digits) -> OUTPUT
  10. :wq to save changes.
  11. Hit Enter to exit lsvirprt

[ Doc Ref: 9174747429818     Publish Date: Feb. 13, 2001     4FAX Ref: 6490 ]