IBM Support

What Is a Virtual Printer?

Question & Answer


Question

What Is a Virtual Printer?

Answer

A virtual printer is a fairly simple interface to a printer. It is the AIX print subsystem's equivalent to the System V print subsystem interface script, but written in a compiled language and much faster. It performs basically these functions:

  1. Initializes the printer.
  2. Provides a hook or interface to filters.
  3. Formats ASCII data
  4. Translates from the input codepage to the output printer symbol set. (ASCII only)
  5. Resets the printer to a predefined condition.
  6. Calls the program to send the header and trailer pages.
  7. Sends a form feed at the end of job

This document applies to all levels of AIX.

What virtual printers do NOT do
Printer initialization
Provides a hook or interface to filters
Formats ASCII data
Code page (symbol set) translation
Printer reset - cr
Header and trailer pages
Sends a form feed at the end of job

What virtual printers do NOT do

  1. Generate any printer language commands such as PostScript or PCL, other than the initialization and reset sequences.
  2. Test for correctness of the format of data.
  3. Automatically recognize the type of data except for very simple sniffing of the first couple of characters, if set up properly.
  4. Act as a print API for applications
Basically the virtual printer does almost nothing for any formatted PCL, formatted PPDS, graphics, or PostScript data except tell the printer what language is coming at it. This means that for formatted data the application must format the data, or you will get simple, one-font text for the document. It also means that if you want color or graphics you must add those through a separate application.

Printer initialization

The virtual printer colon file contains a 'program' that determines what 'initialization' commands are sent to the printer based on the virtual printer 'attribute' settings and command line flags. Examples of commands that are sent at this stage vary greatly by data type. The key virtual printer attributes for the initialize function are the _j flag attribute and the ci 'command to initialize' attribute. If _j=! no initialization commands will be sent. If _j=+ the commands specified by the ci attribute will be sent.

The datastream that the virtual printer expects is determined by an _d or datastream attribute. If this is set:

PostScript:

    For most PostScript virtual printers, the only commands sent to the printer are:
    1. The command to put the printer into PostScript mode. This is usually done with a PJL (Printer Job Language) command such as (ESC%12345Enter Language PostScript)
    2. The command to set the papertray, such as: begin 1 setpapertray end
    3. The command to set the resolution of the printer: begin 300 setresolution end

When ascii data is sent to a PostScript virtual printer with the -da qprt flag, with the a _d attribute set _d=a, or with automatic detection turned on then the 'enscript' command is applied to the ascii data to create PostScript. In this case, many of the flags are used to determine equivalent flags for the enscript command. The data is converted to PostScript and sent to the printer in this manner.

GL:

    Most GL printers and plotters use the virtual printer very similar to the PostScript virtual printer.
     

ASCII, PCL, and PPDS:

    The virtual printers for these data streams do all the things the PostScript virtual printer does as well as to set many other starting conditions. Formatted PCL and PPDS data may reset these conditions and the command may appear to be ignored for these files. The default commands for a a virtual printer are determined by the attributes that start with an underbar. These are called the flag attributes. Some of these attributes can be overridden by command line flags, especially from the 'qprt' print command. The flags that are allowed on the command line are determined by the values inside the square brackets following the %f on the 'ia' attribute for ascii, the 'is' attribute for postscript, 'ic' for pcl. Usually PPDS is considered ASCII.

    The following is a list of most of the attibutes that are used for ASCII data, and what they do:

    For use with qprt, the _x attribute would be used as: qprt -x value

    Attribute    Description
    _E           Double wide 
    printing,  Used most on dot matrix printers
    _I           Font ID, Used 
    only for a few laser printers.  GFID
    _K           Set condensed 
    mode for proprinters, and so on. Not lasers.
    _O           Archaic, Type of 
    paper handling, manual, sheetfeed, continuous.
    _Q           Paper size sent 
    to printer.
    _S           High speed 
    printing option, Not really used.
    _U           + Unidirectional 
    printing, ! bidirectional (impact only)
    _V           Vertical 
    printing, whatever that means, not used.
    _W           + Continuous 
    double wide printing. (impact printers)
    _Y           + or 1 Duplex, - 
    or 0 simplex, 2 duplex/tumble (laser only)
    _e           + emphasized 
    print, - normal print, (mostly impact)
    _j           + Send 
    initialization sequence, ! Don't send initialization
    _k           Color to print 
    entire document.  Not for spot color (not
                 
    currently used.
    _l           Used in this 
    part to send part of page size to printer
                 for 
    impact printers.  See also formatting flags.
    _p           pitch (character 
    size in 1/72 of inch).  This is very
                 
    restricted.  Proprinters usually can have _p=10 or 12 only.
                 Most 
    laser printers will also take _p=17, and it is 
                 
    possible to add more values for some laser printers by
                 
    changing the mU or other attributes accordingly.
    _q           Quality 
    mode.  Mostly used for impact printers,  For laser
                 
    printers this is usually 300 or 600 for dpi.
    _s           Style:  
    This is used by laser printers to designate some
                 of the 
    FIXED point fonts, Usually only courier, italic, and
                 
    lineprinter are allowed.  This can be customized again on
                 some 
    virtual printers by changing teh mU or associated attrib.
    _u           Source of 
    paper.  This is usually used for laser printers to
                 
    designate the paper drawer.
    _v           line density in 
    lines per inch.  Usually this has a fixed
                 value 
    of 6 or 8, but for some laser printers the lines per
                 inch 
    is determined by the page length if more than 60 lines
                 per 
    page.
    _w           page width sent 
    to some impact printers.
    _z           Orientation - 
    (laser printers only) Portrait, Landscape, and so on.
    

Provides a hook or interface to filters

The Flag Attribute dealing with the filtering of data is _f.  A filter is a program that reads the data from standard in, and writes the data to standard out.  What it does in the middle is dependent on the filter.  The output of the filter goes through the rest of the virtual printer program pipeline.
_f           a single 
character that denotes the filter to be used.
             The 
filter program can be found at the attribute starting
             with f 
that contains this letter.  For example if _f=p,
             then 
fp=/usr/bin/pr, and this filter will be run on the
             data 
before it is sent to the virtual printer formatter.
             The 
filter reads from standard in and writes to standard
             out 
and can modify the program in any way.  One example
             is 
'pr' which can add page numbers and provide 2up printing.
             
Another is 'fpr' also called 'asa' which interprets column
             one 
(FORTRAN) carriage control characters.  A third example
             is a 
filter to add carriage returns to line feeds.
The standard filters supplied with AIX ASCII text virtual printers and their associated virtual printer attributes are shown here:

Attribute Program Description
  fc   No Default   cifplot filter
  fd   No Default   Tex (DVI) Filter
  ff   /usr/ucb/fpr   FORTRAN filter: Handles column one control characters.
  fg   No Default   Plot filter
  fl   %ip   Passthrough filter
  fn   /usr/bin/hplj   ditroff filter (like troff formatting)
  fp   /usr/bin/pr   pr filter does formatting similar to virtual printer.  Can create 2-UP text from text.
  ft   No Default   troff filter
  fv   No Default   Raster image file
  f1, f2, f3, f4, f5     No Default   User-specified filters  

To change the virtual printer filter programs or add your own through smit:
Type:  smitty spooler
  Select: Programming Tools
    Select:  Change/Show Pre-processing Filters
       Select the queue to be 
processed.
           Change the 
filter or add one on this page.
                      Change / Show Pre-processing Filters
Type or select values in entry fields.
Press Enter AFTER making all desired changes.
  
                                                        [Entry Fields]
  Print queue name                                    pcl
  Printer name                                        lp0
  
  User defined filter 1                              [/usr/local/bin/myfilt>
  User defined filter 2                              
[/usr/local/bin/overfilt>
  User defined filter 3                              []
  User defined filter 4                              []
  User defined filter 5                              []
  cifplot filter                                     []
  TeX (DVI) filter                                   []
  FORTRAN filter                                     [{ [[ -x /usr/ucb/fpr 
]]>
  plot filter                                        []
  pass-through filter                                [%ip] 
  ditroff filter                                     <fi; /usr/bin/hplj; 
}%ip]
  'pr' filter                                        [/usr/bin/pr -l%IwL 
-w%I>
  troff filter                                       []
  Raster image filter                                []

Formats ASCII data

This applies only to ASCII data, but if this is turned on, it will also format other data, usually with undesired results. Usually one should not use the format option of the virtual printer for PostScript, PCL or PPDS data. Data is formatted if _d=a.

The formatter primarily does the following things:

  1. Determines the values for _w and _l based on the pitch, pagesize, lines per inch, and so on.
  2. Counts characters in a line and adds a line feed after _w characters.
  3. Counts lines and adds a form feed after _l lines.
  4. Adds a formfeed at the end of the job if desired.

Formatting flags:

    _L           + Wrap long 
    lines, ! truncate lines longer than _w
    _Q           Paper size, used 
    to calculate with and length.
    _X           Codepage of 
    input data.
    _Z           + make sure 
    Formfeed sent at end of job
    _b           Number of lines 
    to skip at bottom margin
    _d           Datastream, 
    determined which set of programs is run
         d=s   PostScript Data.  Minimal 
    formatting is done.  This is basically
               a 'transparent or 
    passthrough' formatter.
         d=p   Pass the data through unaltered to the 
    device driver.  This will
               not add a carriage 
    return to line feeds.
         d=c   PCL formatted data handler.
         d=n   troff data filter  (for example 
    with HP uses 'hplj' filter).
         d=g   Hewlett-Packard GL
         d=k   Kanji
         d=d   Diablo 630 datastream
    _g         Page number to restart on 
    printing.  Useful only for ASCII.
    _i         Number of spaces to indent 
    on left column of page.
    _l         Lines per page before 
    formfeed is added.
    _p         Used in calculating page 
    width.
    _t         Top margin in lines.  
    This count will also be used in when
               adding linefeeds 
    after _l lines.
    _v         Used in calculating page 
    length.
    _w         Page width is used to add 
    line feeds after this count is
               exceeded.  
    This can cause problems if you have a graphics
               file that is sent 
    through the formatter.
    _x         Convert line feeds to 
    carriage return and line feed, and so on.
    _z         Orientation - used to 
    calculate page width and length.

Code page (symbol set) translation

Translates from the input codepage to the output printer symbol set.

The stage one translator translates characters in the file from the initial code page (also called symbol set) to to an intermediate. The initial code page is determined by the _X variable and determines what the ASCII characters between 128 and 257 represent. The stage two translator converts the intermediate table to the output symbol set for the printer. This is determined by searching through a set of symbol translation tables until the particular character is found. Then the command is sent to the printer to change to that code page. This command is only sent once until the character is no longer found in that code page and then it sends the command for the new symbol set.

_X         Input codepage assumed 
for data.  At AIX 3.2.5 in the U.S.
           this is 
IBM-850.  At AIX 4.1 this is ISO8859-1.  These can
           give different 
results with different files.
           There are no flags 
for the output symbol sets, but the search
           list is usually 
given by the t0, t1, t2, .. attributes.

Printer reset - cr attribute

Resets the printer to a predefined condition.

Based on the value of the _J attribute, the command to reset the printer, which is the 'cr' attribute, can be sent. This usually doesn't matter too much. In general this will send the same commands as the initialization command except that it will always use the virtual printer attribute and not the command line print flags.

_J + Send the reset commands, ! Don't reset after printing.


Header and trailer pages

Calls the program to send the header and trailer pages.

There are no flag attributes for the header and trailer pages. These are contained in the /etc/qconfig file, or by command line flags such as -Ban for qprt and enq. The lpr command sends a flag to send headers by default. If an application uses this command and you cannot specify options, headers can be turned off by disabling the sh header page filter attribute, set sh=[enter], so that it is set to nothing.


Sends a form feed at the end of job

At the end of a job the virtual printer insures that the page will be ejected from the printer by sending a form feed. This is controlled by the _Z attribute, and the form feed will even be sent in passthrough mode. If you are getting an extra page at the end of a formatted job, set _Z=!. This will usually help because the file might already have a form feed, and with the one from the virtual printer there may be two.

[{"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"}}]

Historical Number

isg1pTechnote0428

Document Information

Modified date:
17 June 2018

UID

isg3T1000278