AIX Printer Tips - What Is a Virtual Printer?


Contents

About This Document
Virtual Printers do NOT
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

About This Document

A virtual printer is a fairly simple interface to a printer. 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.


Virtual Printers do NOT

  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:

When ascii data is sent to a PostScript virtual printer with the -da qprt flag or with the a _d attribute set _d=a, 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:

ASCII, PCL, and PPDS:


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:


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

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 sh, 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.


What Is a Virtual Printer?: AIX Printer Tips: vpwhat.html ITEM: FAX
Dated: 99/02/16~00:00 Category: zap
This HTML file was generated 99/06/24~12:42:13
Comments or suggestions? Contact us