IBM Support

Expanding Options for Page Orientation

Question & Answer


Question

Expanding Options for Page Orientation

Answer

The AIX virtual printer allows two page-orientation options for most laser printers (portrait and landscape). Some printers support additional orientations such as portrait tumble and landscape tumble, also called reverse portrait and reverse landscape. This document describes how to expand the virtual printer options to allow the selection of more page-orientation options.

The instructions in this document are specific to AIX Versions 4 and 5 without the limits fields.

NOTE: The printer you are printing to must support the additional options.

Overview
Determining the necessary information
Changing the virtual printer
Create a queue and test

Overview

Landscape options for AIX virtual printers are described in the "Portrait and Landscape" section of the technical document AIX Printer Tips: Virtual Printer Overview.

At AIX 4 and 5, the allowed virtual printer options are determined by a limits field. This field determines two things:

  1. What options will show up on the smit chpq screens
  2. What values will be allowed for flag options when printing or changing virtual printers

Based on the predef templates, it becomes readily apparent that the PCL printers get their _z attribute from the generic.pcl file. The _z attribute in generic.pcl is:

:618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,620;portrait,landscape=!,+]:!

This means that the only options that you will see are landscape and portrait.

The man pages on qprt indicate that there are 4 values for orientation:

  1. Portrait
  2. Landscape right
  3. Portrait upside-down
  4. Landscape left

Yet most of the printer definitions only had '+' and '!' for values. The qprt command would give errors on invalid values for the -z flag using anything other than + or !.

The objective of this document is to describe how to make changes to a virtual printer predef file to support these options. The examples are for a PCL printer.


Determining the necessary information

  1. What are the printer codes allowed by the printer?

    For example, for the HP LaserJet Family the PCL values are:

       Function  Parameter    Command     Decimal Value        Hexadecimal
                                                                  Value
      Orientation
       Orientat Portrait     Ec&0O     027 038 108 048 079   1B 26 6C 30 4F
       ion                   (o)       (111)                 (6F)
                Landscape    Ec&1O     027 038 108 049 079   1B 26 6C 31 4F
                             (o)       (111)                 (6F)
                Reverse      Ec&2O     027 038 108 050 079   1B 26 6C 32 4F
                Portrait     (o)       (111)                 (6F)
                Reverse      Ec&3O     027 038 108 051 079   1B 26 6C 33 4F
                Landscape    (o)       (111)                 (6F)
    
  2. What are the catalog messages available to use?

    The messages that are used by the virtual printer program can be displayed with the dspcat command. An appropriate message to use would be one with landscape or portrait, so try the following:

    # dspcat pioattr1.cat | grep landscape
     1 : 107 Rotate Page Printer Output (!:no - portrait  +:yes - landscape)
     1 : 620 portrait,landscape
     1 : 725 portrait,landscape right,portrait upside-down,landscape left
     1 : 751 portrait,landscape left,portrait upside-down,landscape right
     1 : 950 Rotate Page Printer Output (0: portrait  1: landscape)
    

    Pick out the one that makes sense, and use that as the number replacing the 620 above. Let's say we wanted to use the 725 value above.

  3. What are the virtual printer attributes that use the _z attribute to determine what is sent to the printer?

    • # grep _z generic.pcl
      1. :618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,620;portrait,landscape=!,+]:!
      2. :679:W4::%?%G_z%t%GwR%e%GwK%;%gv%*%{300}%/%d
      3. :517:wj::%?%G_z%{1}%&%t%GwM%e%GwJ%;%d
      4. :518:wk::%?%G_z%{1}%&%t%GwR%e%GwK%;%d
      5. :202:eO::\33&l%G_z%dO

      Based on these attributes, it is obvious to the trained eye that:

      1. _z is the flag attribute and has limited input values of ! and + for portrait and landscape.
      2. W4 is used to select some time of increment based on page sizes
      3. wj is used to select the values to determine page width or length
      4. wk is used to select the values to determine page width or length
      5. eO is the attribute that builds the PCL command that will be sent to the printer.

      Those with an untrained eye should use lsvirprt and see the description for each attribute.

      1. _z - Page ORIENTATION
      2. W4 - Determine lines per page based on lines per inch
      3. wj - Page Width in Current Orientation (pels)
      4. wk - Page Length in Current Orientation (pels)
      5. eO - Specify the page orientation

      You might also notice that eO is included in the ci attribute, and so it will be sent to the printer during printer initialization. This means that we will have to change or at least be aware of the effects of changing _z on these attributes.

    • # grep _z hplj-4.pcl (for example)
      • Nothing is returned, so this gets all of its values from the generic.pcl template.

Changing the virtual printer

    At AIX 4, changes that will affect limits need to be made in the predef templates because these are used to build the SMIT screens. The other option is to actually make odm commands to change SMIT, but this is a more dangerous option for the uninitiated.

    Changing the _z attribute

    This example uses the hplj-4.pcl predef file, but it is generally applicable to other PCL drivers.

    First, create a virtual printer with the original driver for later comparison.

    Follow these steps:

    1. mkdir /home/oldfiles

    2. cp hplj-4.pcl /home/oldfiles/hplj-4.pcl_orig
      Move it to another directory because leaving it in predef will just add to the confusion when adding printers.

    3. vi hplj-4.pcl

    4. Add a single line in the __FLG section of the file:
      :618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,725;portrait,landscape 
      right,portrait upside-down,landscape left=0,1,2,3]:0
      

      What does all this mean?

      • :618: is the message number in pioattr1.cat. You can view it with dspcat. The catalog Set is 1, the message number is 618.
        dspcat pioattr1.cat 1 618
        Page ORIENTATION
        

      • :S[E005] - This is the location that this will show in the smit chpq menus. This will show up in the same section of the page with other E selections, such as _u, _Y and _Q.

      • I[1810520] is the Help Screen.

      • En - You need to look this up under limit screen once info is up on your server again.

      • R - This will be a Ring List and users can select from a menu.

      • pioattr1.cat - This is the message catalog for the menu selections.

      • 1,175 - This is the location in pioattr1.cat to look for the message that will show up as the text for the ring list in SMIT. The number 175 was chosen from the dspcat pioattr1.cat | grep landscape command issued earlier.
         1 : 725 portrait,landscape right,portrait upside-down,landscape left
        
      • portrait,langscape right, portrait, upside-down,landscape left - These are the text that will be used if the pioattr1.cat field cannot be found.

      • 0,1,2,3 - These are values corresponding to the 4 text fields.

      • :0 - This is the default value for the attribute.

    Changing the W4 attribute

    Use the virtual printer you created from the original.

    1. lsvirprt

    2. Select the virtual printer from the original

    3. Type: W4~v (this is 'W4 tilde v')
      Determine lines per page based on lines per inch
      W4 = %?%G_z%t%GwR%e%GwK%;%gv%*%{300}%/%d
       %?            <IF>
           %G_z      PUSH: (Page ORIENTATION)
       %t            <THEN>
           %GwR      PUSH: (Page Length (pels) For Landscape Orientation)
       %e            <ELSE>
           %GwK      PUSH: (Page Length (pels) For Portrait Orientation)
       %;            <END>
       %gv           PUSH: (Internal Variable v)
       %*            PUSH: (pop2 * pop1)
       %{300}        PUSH: (Integer Constant 300)
       %/            PUSH: (pop2 / pop1)
       %d            POP -> ASCII String -> OUTPUT
      ~
      

      You need to modify this so it uses Landscape for values 1 and 3, and portrait for values 0 and 2. This can be done by changing to:

      Determine lines per page based on lines per inch
      W4 = %?%G_z%t%GwR%e%GwK%;%gv%*%{300}%/%d
       %?            <IF>
           %G_z      PUSH: (Page ORIENTATION)
           %{1}       /* Add constant 1 to check for comparison */
           %&         /* See if the orientation and with constant 1 */
                      /* This will hold for both 1 and 3      */
       %t            <THEN>
           %GwR      PUSH: (Page Length (pels) For Landscape Orientation)
       %e            <ELSE>
           %GwK      PUSH: (Page Length (pels) For Portrait Orientation)
       %;            <END>
       %gv           PUSH: (Internal Variable v)
       %*            PUSH: (pop2 * pop1)
       %{300}        PUSH: (Integer Constant 300)
       %/            PUSH: (pop2 / pop1)
       %d            POP -> ASCII String -> OUTPUT
      ~
      

      Save these changes, and then check the value in the custom file, so you can add it to the new predef file.

    4. cd /var/spool/lpd/pio/@local/custom

    5. ls and look for the name that has your queue name in it.

    6. vi queue_name

    7. Find :W4:

    8. Change line to
      :679:W4::%?%G_z%{1}%&%t%GwR%e%GwK%;%gv%*%{300}%/%d
      
    9. Now copy the preceding line back to the predef file after the :062:__WKV:: line.

      This line gives the following pseudo-code interpretation:

      If (_z AND 1 ) 
         Use Landscape Settings to determine lines per page increment
      else
         Use Portrait Settings to determine lines per page increment.
      endif
      

    Changing the wj attribute

    Looking at the wj attribute you see:

    • :517:wj::%?%G_z%{1}%&%t%GwM%e%GwJ%;%d

    The pseudo-code for this is

    If (_z AND 1 ) 
       Use Landscape Settings to determine lines per page increment
    else
       Use Portrait Settings to determine lines per page increment.
    endif
    

    This should work fine as is, and no changes are required.

    Changing the wk attribute

    This wk attribute default is:

    • :518:wk::%?%G_z%{1}%&%t%GwR%e%GwK%;%d

    This again has the same pseudo-code meaning and does not need to be changed.

    Changing the eO attribute

    You probably don't need to change this value because it expands to fit the required command. This command sends out the sequence: ESC&l#O where # = the _z value or the -z flag.

        :202:eO::\33&l%G_z%dO
    

    Summary of Lines to be added to the predef file

    1. :618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,725;portrait,landscape right,portrait upside-down,landscape left=0,1,2,3]:0
    2. :679:W4::%?%G_z%{1}%&%t%GwR%e%GwK%;%gv%*%{300}%/%d

    Excerpt from the hplj-4.pcl predef file:

    ...
    :712:_q:S[B045]I[1810554]EnR[=300,600]:300
    :618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,725;portrait,landscape right,
               portrait upside-down,landscape left=0,1,2,3]:0
    :060:__SYS::
    ......
    :062:__WKV::
    :679:W4::%?%G_z%{1}%&%t%GwR%e%GwK%;%gv%*%{300}%/%d
    :689:W6::%?%GWu%{3}%<%GWu%{5}%>%|%t%IWP%e%IWE%;
    ...
    


Create a queue and test

  1. Use: smitty mkpq and choose your printer type (for example, HP LaserJet 4).

  2. Enter a PCL queue name.

  3. Change the queue with smitty chpq

  4. Choose Option 2: Change / Show Default Print Job Attributes

  5. Look for: Page ORIENTATION

  6. Popup Menu Now Shows
    portrait
    landscape right
    portrait upside-down
    landscape left
    
  7. Select the desired option, then print to queue.
    qprt -z allowed values should now equal 0,1,2,3.

[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Attached devices","Platform":[{"code":"PF002","label":"AIX"}],"Version":"5.3;5.2;5.1;4.3","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}},{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"File management","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Historical Number

isg1pTechnote0284

Document Information

Modified date:
17 June 2018

UID

isg3T1000170