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.
OverviewDetermining 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:
- What options will show up on the smit chpq screens
- 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:
- Portrait
- Landscape right
- Portrait upside-down
- 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
- 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) - 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.
- What are the virtual printer attributes that use the _z
attribute to determine what is sent to the printer?
- # grep _z generic.pcl
- :618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,620;portrait,landscape=!,+]:!
- :679:W4::%?%G_z%t%GwR%e%GwK%;%gv%*%{300}%/%d
- :517:wj::%?%G_z%{1}%&%t%GwM%e%GwJ%;%d
- :518:wk::%?%G_z%{1}%&%t%GwR%e%GwK%;%d
- :202:eO::\33&l%G_z%dO
Based on these attributes, it is obvious to the trained eye that:
- _z is the flag attribute and has limited input values of ! and + for portrait and landscape.
- W4 is used to select some time of increment based on page sizes
- wj is used to select the values to determine page width or length
- wk is used to select the values to determine page width or length
- 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.
- _z - Page ORIENTATION
- W4 - Determine lines per page based on lines per inch
- wj - Page Width in Current Orientation (pels)
- wk - Page Length in Current Orientation (pels)
- 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.
- # grep _z generic.pcl
Changing the virtual printer
- mkdir /home/oldfiles
- 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. - vi hplj-4.pcl
- 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.
- :618: is the message number in pioattr1.cat. You can view it
with dspcat. The catalog Set is 1, the message number is 618.
- lsvirprt
- Select the virtual printer from the original
- 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.
- cd /var/spool/lpd/pio/@local/custom
- ls and look for the name that has your queue name in it.
- vi queue_name
- Find :W4:
- Change line to
:679:W4::%?%G_z%{1}%&%t%GwR%e%GwK%;%gv%*%{300}%/%d - 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
- :517:wj::%?%G_z%{1}%&%t%GwM%e%GwJ%;%d
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:
Changing the W4 attribute
Use the virtual printer you created from the original.
Changing the wj attribute
Looking at the wj attribute you see:
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
- :618:_z:S[E005]I[1810520]EnR[pioattr1.cat,1,725;portrait,landscape right,portrait upside-down,landscape left=0,1,2,3]:0
- :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
- Use: smitty mkpq and choose your printer type (for example, HP
LaserJet 4).
- Enter a PCL queue name.
- Change the queue with smitty chpq
- Choose Option 2: Change / Show Default Print Job Attributes
- Look for: Page ORIENTATION
- Popup Menu Now Shows
portrait landscape right portrait upside-down landscape left
- Select the desired option, then print to queue.
qprt -z allowed values should now equal 0,1,2,3.
Historical Number
isg1pTechnote0284
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
isg3T1000170