GS-HPDJ(1)                                                          GS-HPDJ(1)



[1mNAME[0m
       hpdj - Ghostscript device driver for printers understanding PCL 3+


[1mSYNOPSIS[0m
       [1mgs [22m[[4moptions[24m] [[4mfiles[24m]
       [4moption[24m ::= [4mprn_option[24m | [4mhpdj_option[0m

       [4mprn_option[24m  can  be  any option defined for ghostscript's [4mprn[24m (printer)
       device.  This includes  all  device-independent  options  described  in
       [4mgs(1)[24m.   You should also look into ghostscript's extended documentation
       (file  Use.htm/use.txt  and  the  section  [4mDevice[24m  [4mparameters[24m  in  Lan-
       guage.htm/language.txt).   [4mhpdj[24m  does  not support the Duplex parameter
       and it determines the correct value for BitsPerPixel automatically.

       [4mhpdj_option[24m ::= [1m-dBlackLevels[22m=[4minteger[24m | [1m-dCMYLevels[22m=[4minteger[24m |
           [1m-sColorMode=[4m[22mmode[24m | [1m-sColourMode=[4m[22mmode[24m | [1m-dCompressionMethod=[4m[22mmethod[24m |
           [1m-dDryTime=[4m[22mseconds[24m | [1m-dManualFeed[22m[[1m=[4m[22mboolean[24m] | [1m-sMarginFile=[4m[22mpathname[0m
           | [1m-sMediaType=[4m[22mtype[24m | [1m-sModel=[4m[22mmodel[24m | [1m-sPagecountFile=[4m[22mpathname[24m |
           [1m-sPrintQuality=[4m[22mquality[0m
       [4mmode[24m ::= [1mmono [22m| [1mCMY [22m| [1mCMY+K [22m| [1mCMYK[0m
       [4mmethod[24m ::= [1m0 [22m| [1m1 [22m| [1m2 [22m| [1m3 [22m| [1m9[0m
       [4mboolean[24m ::= [1mfalse [22m| [1mtrue[0m
       [4mtype[24m ::= [1mplain [22m| [1mbond [22m| [1mPremium [22m| [1mglossy [22m| [1mtransparency [22m| [1mphoto [22m|
           [4minteger[0m
       [4mmodel[24m ::= [1m500 [22m| [1m500C [22m| [1m510 [22m| [1m520 [22m| [1m540 [22m| [1m550C [22m| [1m560C [22m| [1m850C [22m| [1m855C [22m|
           [1munspec[0m
       [4mquality[24m ::= [1mdraft [22m| [1mnormal [22m| [1mpresentation [22m| [4minteger[0m

       Case is significant.  Note that some options must be passed as  strings
       ([1m-s[22m)  and  others as general tokens ([1m-d[22m).  You should also keep in mind
       that [4mgs[24m effectively ignores every option it does not  recognize,  hence
       some care in spelling parameter names is necessary.

       Some  options have synonyms for values which are listed only in the de-
       tailed description below.


[1mDESCRIPTION[0m
   [1mScope[0m
       The ghostscript device driver [4mhpdj[24m is a ghostscript backend for  print-
       ers  understanding Hewlett-Packard's Printer Command Language, level 3+
       (PCL 3+).  It is intended to support in particular the following print-
       er models:

           HP DeskJet 500
           HP DeskJet 500C
           HP DeskJet 510
           HP DeskJet 520
           HP DeskJet 540
           HP DeskJet 550C
           HP DeskJet 560C
           HP DeskJet 850C
           HP DeskJet 855C

       The  driver does [4mnot[24m support DeskJet printers understanding only HP PPA
       (Printing Performance Architecture) commands.  If a printer's  documen-
       tation  does not say anything about its printer command language or you
       find a statement like "... is designed for Microsoft Windows"  or  "DOS
       support  through  Windows  only", the printer is almost certainly a PPA
       printer and hence is intended [4mexclusively[24m for systems running Microsoft
       Windows.  There exist ways of using a PPA printer with ghostscript, but
       not through [4mhpdj[24m.

       Different printer models usually implement  model-specific  subsets  of
       all  PCL-3+ commands or arguments to commands.  You must therefore tell
       the driver by means of the [1mModel [22moption for which model  the  generated
       PCL  code is intended.  The model-dependent difference in the generated
       code is not great.  Apart from margin specifications and  colour  capa-
       bilities,  one  can  consider  three groups of models which are treated
       with significant differences:

           500,
           5xx except 500 and 540,
           540 and 8xx.

       The third group is the one I refer to as the "new DeskJets" below.

       If you have a PCL-3 printer not appearing in the list above, the  like-
       lihood  is  still good that it will accept the files generated by [4mhpdj[24m.
       You can specify one of the supported models in these cases (it is  suf-
       ficient  to  try  one  each from the groups just mentioned), or use the
       special model name [1munspec [22mwhich is treated like a new DeskJet with  all
       model-dependent checks having been turned off.

       I have received reports that [4mhpdj[24m works with the following printers:

           HP DeskJet 340
           HP DeskJet 500
           HP DeskJet 500C (tested for mono only)
           HP DeskJet 520
           HP DeskJet 540
           HP DeskJet 560C
           HP DeskJet 600
           HP DeskJet 660C/660Cse
           HP DeskJet 670C
           HP DeskJet 672C
           HP DeskJet 680C
           HP DeskJet 690C
           HP DeskJet 690C+
           HP DeskJet 693C
           HP DeskJet 694C
           HP DeskJet 850C
           HP DeskJet 855C
           HP DeskJet 870Cse/870Cxi
           HP DeskJet 880C
           HP DeskJet 890C
           HP DeskJet 895Cse/Cxi
           HP DeskJet 1100C
           HP DeskJet 1120C
           HP OfficeJet 590
           HP OfficeJet 600
           HP OfficeJet 625
           HP 2000C/Cse/CN Professional Series Color Printer
           Lexmark 3000 Color Jetprinter

       Usually  the  people  who  send me reports do not state to which extent
       [4mhpdj[24m "works" for their printer model.

       I should like to extend this section with  more  specific  information.
       Therefore, if you want to report success for a particular printer model
       not explicitly supported by [4mhpdj[24m, please mention the following items in
       your answer:

          printer model
          [4mgs[24m version
          [4mhpdj[24m version
          option  combinations  successfully  tested (specify at least model,
           resolution, colour mode and, if used, the number of intensity  lev-
           els)
          printer-specific functionality you could not access

       So  far  I have not heard of a PCL-3+ printer which cannot be driven by
       [4mhpdj[24m.  Hence the really interesting part of success reports is the list
       of  working option combinations, but since I included the above request
       in this manual page in December 1997, hardly anyone has sent me such  a
       report.  Possibly, users find this information unnecessary.

   [1mColour Modes[0m
       Ignoring  photo  cartridges, DeskJet printers can be classified in four
       categories:

        The printer has only a black ink cartridge.

        The printer can print with either a black  or  a  cyan/magenta/yellow
         (CMY) cartridge.

        The printer holds a CMY and a black cartridge simultaneously, but the
         inks are chemically incompatible and should not be overlayed.  (Don't
         worry:  the  printer  is not going to explode if they do.  You merely
         get poorer results because the black ink will spread further than  it
         should.)

        The  printer holds a CMY and a black cartridge simultaneously and the
         inks can be mixed.

       This leads to four [4mcolour[24m [4mmodes[24m for the driver:

       mono:   Print in black.

       CMY:    Print in cyan, magenta and yellow only.  In this mode, "compos-
               ite black" consisting of all three inks is used to stand in for
               true black.

       CMY+K:  Print with all four inks, but never mix black with one  of  the
               others.

       CMYK:   Print with all four inks.

       Depending  on  the category of the model chosen, the driver will accept
       one or more of these modes.  The possibilities are:


           Model                Colour Modes
           --------------------------------------
           500, 510, 520        mono
           500C, 540            mono, CMY
           550C, 560C           mono, CMY, CMY+K
           850C, 855C, unspec   all

       Note that a printer capable only of CMY might accept CMY+K or CMYK  da-
       ta,  remapping  them to CMY, and a printer capable of CMY+K might remap
       CMY data to CMY+K.

   [1mPrint Quality Selection for Older DeskJets[0m
       With the introduction of the DeskJet 540, HP added two new PCL commands
       to  the  language:  Media  Type  and Print Quality.  For older DeskJets
       (500, 500C, 510, 520, 550C and 560C), similar effects can  be  achieved
       by specifying some technical aspects of the printing process in detail.

       The [4mhpdj[24m driver accepts only the new Media Type and Print Quality spec-
       ifications as options.  For printers not  understanding  the  new  com-
       mands,  these  specifications  are mapped to the older Depletion, Shin-
       gling, and Raster Graphics Quality commands  based  on  recommendations
       from HP.

   [1mMedia Sizes and Orientations[0m
       Ghostscript  looks  at several sources to determine the page size for a
       document:

          the default size set for [4mgs[24m (usually US Letter or ISO A4)
          the value given to [1m-sPAPERSIZE [22min the invocation
          the size requested by the document, unless you specify [1m-dFIXEDMEDIA[0m

       The last applicable item in this list overrides the others.

       The driver knows which media sizes are supported by each printer  model
       and will refuse to print if an unsupported one is requested.  The model
       [1munspec [22mnormally accepts all sizes, and it assumes the printer to under-
       stand  all  size commands which can be sent to one of the supported se-
       ries-800 DeskJets.  This can be changed with a margin  file  specifica-
       tion; see the [4mCONFIGURATION[24m section below for details.

       Each supported size is available in portrait and landscape orientation.
       Media should however always be put into the input tray  independent  of
       the  intended  orientation.  Ghostscript and [4mhpdj[24m will take care of the
       rest.  Hewlett-Packard's information on the required orientation of me-
       dia in the input tray is not quite clear, but [4mhpdj[24m assumes it to be al-
       ways "short edge first" with respect to  the  feeding  direction.   You
       should check your printer's manual whether this is correct, in particu-
       lar if you have a DeskJet 400, 500 or 500C and wish  to  print  on  en-
       velopes.  Note that [4mhpdj[24m has no information about the dimension or ori-
       entation of the medium in the input tray: you must ensure yourself that
       this is appropriate.

       In  setting  up  the PostScript default user space, [4mhpdj[24m does not treat
       envelope sizes differently.

   [1mDiagnostic Messages[0m
       Error messages issued by [4mhpdj[24m start with  "?  Device  hpdj:",  warnings
       with  "?-W  Device  hpdj:".   Both  are  written  on the standard error
       stream.


[1mOPTIONS[0m
       The following options are not specific to the [4mhpdj[24m device but have spe-
       cific meaning or restrictions:

       [1m-sDEVICE=hpdj[0m
           This option specification selects this driver.

       [1m-r[4m[22mresolution[0m
           This option specifies the resolution in pixels per inch (ppi).  The
           driver checks whether the model selected accepts the given  resolu-
           tion unless the model is [1munspec[22m.  Resolutions supported by at least
           some of the models in some of the colour modes are  75,  100,  150,
           300 and 600 ppi.  Only [1munspec [22mpermits unequal horizontal and verti-
           cal resolutions.  For this case read the subsection on the  Config-
           ure  Raster  Data  command  in the [4mLIMITATIONS[24m section below first.
           The default resolution for [4mhpdj[24m is set at compile time, usually  to
           300 ppi.

       The following options are specific to [4mhpdj[24m:

       [1m-dBlackLevels=[4m[22mlevels[24m and [1m-dCMYLevels=[4m[22mlevels[0m
           [1mWarning! These options are not based on HP documentation!  [22mRead the
           subsection on the Configure Raster Data command in the  [4mLIMITATIONS[0m
           section below before using them.

           These options set the number of intensity levels per pixel and col-
           orant to use when printing with black or  CMY  inks,  respectively,
           and must be consistent with the colour mode.  They permit access to
           the Colour Resolution Enhancement technology (C-REt) feature avail-
           able in some series-800 DeskJets.  The defaults are 0 or 2, depend-
           ing on the colour mode chosen.  Other values are only accepted  for
           the  models [1m850C[22m, [1m855C [22mand [1munspec[22m.  I strongly suggest that you ap-
           ply gamma correction and modify the halftone screens  whenever  you
           use  non-default  values  for  these options (see the [4mCONFIGURATION[0m
           section below).

           [1munspec [22maccepts any non-negative number of levels  except  1  up  to
           256.  The models [1m850C [22mand [1m855C [22maccept the [4mlevels[24m 0, 2, 3 and 4 with
           the following restrictions if any of the levels is larger than 2:
              You can't use this feature with draft quality.
              You can't use a colour mode of [1mCMY[22m.
              You must use a resolution of 300 ppi.
              If you are using a non-monochrome mode, you must use  4  levels
               for black.
           When  using the model [1munspec [22myou should expect the printer to simi-
           larly limit the possibilities.  So far I have not heard of a PCL-3+
           printer supporting more than four intensity levels per colorant.

           Unfortunately, there is a problem here because ghostscript's inter-
           nal colour model is not prepared for the situation where  a  device
           can  render  different small (< 32) numbers of intensity levels for
           different colorants.  In this situation [4mgs[24m will in  general  assume
           that  the number of black levels available is equal to that for CMY
           levels.  Depending on which of the numbers is smaller,  there  will
           then  either  be unused black levels or some will be used more than
           once.

           Regrettably, best results on a  DeskJet  850C  seem  to  me  to  be
           achieved  with  4  black and 3 CMY levels, at least on plain paper.
           (4 CMY levels might be right for presentation quality on glossy pa-
           per or transparencies.)  The [4mCONFIGURATION[24m section below presents a
           slightly dirty path out of this difficulty.

       [1m-sColorMode=[4m[22mmode[24m  or  [1m-sColourMode=[4m[22mmode[0m
           This selects the colour mode to be used by  the  driver:  [1mmono  [22m(or
           [1mmonochrome[22m),  [1mCMY[22m,  [1mCMY+K  [22mor  [1mCMYK[22m.   The  default is [1mmono[22m.  Which
           colour modes are accepted depends on the model, see [4mColour[24m [4mModes[24m in
           the section [4mDESCRIPTION[24m above.

           A  value  of [1mCMY [22mfor this option also sets [1mBlackLevels [22mto zero, and
           if [1mCMYLevels [22mis zero when you demand any of [1mCMY[22m, [1mCMY+K [22mor [1mCMYK[22m,  it
           is  set  to two.  For all other situations you must ensure yourself
           that colour mode and intensity levels are consistent or  [4mhpdj[24m  will
           complain.   This rule implies that you can ignore the level options
           unless you want to use a non-default number of levels.

           The PostScript page device dictionary entry ProcessColorModel  will
           not be correct for a colour mode of [1mCMY [22mor [1mCMY+K[22m.

       [1m-dCompressionMethod=[4m[22mmethod[0m
           PCL  interpreters understand several compression methods for raster
           graphics data in order to speed up host-printer communication.  The
           possible choices are:

             [1m0  [22mUnencoded, non-compressed
             [1m1  [22mRunlength encoding
             [1m2  [22mTagged Image File Format (TIFF)
             [1m3  [22mDelta Row Compression
             [1m9  [22mCompressed Replacement Delta Row Encoding

           The  default method is set at compile time, usually to 9.  Request-
           ing method 3 actually leads to a combination of methods  2  and  3.
           The  DeskJet  500 does not support method 9.  The driver may tempo-
           rarily choose method 0 if  a  compressed  data  sequence  would  be
           longer than its uncompressed version.

           Compression  rates can vary drastically, depending on the structure
           of the input.  However, although the absolute  values  change,  the
           relative order of efficiency between the methods is usually the or-
           der of increasing [4mmethod[24m.  In  short:  use  method  9  (3  for  the
           DeskJet 500).

       [1m-dDryTime=[4m[22mdelay[0m
           With  the  exception of the DeskJets 500 and 500C, DeskJet printers
           can be told to guarantee a minimum drying time of [4mdelay[24m seconds be-
           fore  the  next  page  of  the same print job is dropped on a newly
           printed page.  (This interval can be  terminated  by  pressing  the
           Load/Eject button.)  The printer will choose default values depend-
           ing on the current print quality, hence it is normally  not  neces-
           sary  to specify this option and the feature is even considered ob-
           solete for newer DeskJets although it is still supported by some of
           them.

           Permissible  values for [4mdelay[24m are integers in the range [1m-1 [22mto [1m1200[22m,
           where [1m-1 [22minstructs [4mhpdj[24m not to send a corresponding command, [1m0  [22mes-
           tablishes  default  values  for  the current print quality, and all
           other values explicitly request the duration in seconds.   The  de-
           fault is [1m-1[22m.

       [1m-dManualFeed[22m[[1m=[4m[22mboolean[24m]
           It  is  possible  to  request a DeskJet printer to wait before each
           page of a document until the Load/Eject button is  pressed  on  the
           printer.  This is mostly intended for situations where some special
           medium is used or the medium has to be inserted into an input  slot
           holding only one sheet at a time.  The default setting for this op-
           tion is [1mfalse [22mexcept for series-500 DeskJets printing  on  envelope
           sizes when it is [1mtrue[22m.

           Note that for current ghostscript versions this setting is indepen-
           dent of the value of the PostScript operator manualfeed in  status-
           dict.   If  you want to set manual feeding from the PostScript code
           you must therefore use the ManualFeed entry in the page device dic-
           tionary.

       [1m-sMarginFile=[4m[22mpathname[0m
           This option must specify an existing file containing a list of sup-
           ported media sizes and corresponding margin  descriptions  for  the
           printer.  This will take precedence over the builtin model-specific
           lists of sizes and margins.  The format of the file is described in
           the  [4mCONFIGURATION[24m section below.  The default is not to use a mar-
           gin file but the builtin lists.  This option is primarily  intended
           to be used with the model [1munspec[22m.

           A margin file path can also be specified at compile time overriding
           the default behaviour for [1munspec [22monly.  Using the [1mMarginFile [22moption
           in addition will override the compiled-in margin file path.

       [1m-sMediaType=[4m[22mtype[0m
           This option selects (you guessed it) the type of medium you wish to
           print on.  The possible choices are:
               [1m0  plain paper[0m
               [1m1  bond paper[0m
               [1m2  HP Premium paper[0m
               [1m3  glossy paper[0m
               [1m4  transparency film[0m
               [1m5  photo paper[0m

           The default is [1mplain paper[22m.  For [4mtype[24m, you  can  specify  the  full
           strings,  the  one-word  strings  resulting  from dropping "paper",
           "film", and "HP", or an  integer.   Out-of-range  numerical  values
           generate a warning but are passed through to the printer if it is a
           model understanding the PCL command "Media Type".  If it isn't, the
           effect  is  the  same as specifying [1mplain paper[22m.  The value [1m5[22m/[1mphoto[0m
           [1mpaper [22mis only understood by some recent DeskJets (e.g., the DeskJet
           690C) and will be ignored by older ones.

       [1m-sModel=[4m[22mmodel[0m
           This  option  identifies  the printer model for which the generated
           file is intended.  The following names are accepted for [4mmodel[24m:

               [1m500[22m, [1m500C[22m, [1m510[22m, [1m520[22m, [1m540[22m, [1m550C[22m, [1m560C[22m, [1m850C[22m, [1m855C[22m, [1munspec[22m.

           The choice of model primarily determines which resolutions,  colour
           modes,  intensity  levels  and  media sizes the driver will accept,
           where the output will appear on the page, and to some  extent  what
           PCL  code the driver will generate.  Some of the models are treated
           identically.  A default model can be set at compile time.  If  this
           has not been done, you must specify the [1mModel [22moption in every invo-
           cation.

           [1munspec [22mis intended to be a stop-gap for DeskJet-compatible printers
           not presently supported by this driver.  For [1munspec[22m, all model-spe-
           cific checks (e.g., supported resolutions) are  turned  off.   Sup-
           ported  media sizes and margin settings are assumed to be identical
           with those for the DeskJets 850C/855C/870C/890C, but  you  can  use
           the  [1mMarginFile  [22moption  or its compile-time equivalent to override
           this.  The PCL code generated assumes a "new" DeskJet in the  sense
           that it should be at least at the level of a DeskJet 540 supporting
           the PCL commands Media Type and Print Quality.  If you specify  un-
           equal  horizontal  and vertical resolutions or more than two levels
           of intensity per colour and pixel, the printer must in addition un-
           derstand the Configure Raster Data command.  Read the subsection on
           that command in the [4mLIMITATIONS[24m section below.

           If you choose to use [1munspec [22mit is  your  responsibility  to  ensure
           that [4mhpdj[24m is only called with parameter values the printer can han-
           dle.  This applies in particular to the resolution and the intensi-
           ty levels.

       [1m-sPagecountFile=[4m[22mpathname[0m
           The [4mpathname[24m must specify either a non-existent file in a directory
           with write permission or a writable file with a  single  line  con-
           taining  a non-negative integer.  In the first case, [4mhpdj[24m will cre-
           ate the file and insert the number of pages processed, in the  sec-
           ond  case  the number will be incremented by that amount.  Parallel
           invocations of [4mgs[24m are permitted to use the same  file.   [4mhpdj[24m  will
           also  make the initial page count available in its page device dic-
           tionary.  Note that in present ghostscript versions the  PostScript
           operator  pagecount  in  statusdict  always returns 4711 and is not
           based on the value of PageCount in the page device dictionary.

           This option is mainly intended for spooler backends  calling  [4mhpdj[24m.
           It  can  be used to keep track of the total number of pages printed
           and also for per-job accounting.  I recommend using this option for
           the first purpose and to make a note of the values in the resulting
           files whenever you insert a new ink cartridge.   This  will  enable
           you  to  get an indication of how much a printed page costs and why
           it is a good idea to use [1mdraft [22mquality whenever possible.

           The driver can be compiled without this option  present  but  on  a
           UNIX system I would not expect this to be done unless [4mgs[24m offers the
           same functionality in a driver-independent manner which it current-
           ly does not.

           [4mhpdj[24m  is distributed with an example if-hpdj of a BSD spooler back-
           end using this option.

       [1m-sPrintQuality=[4m[22mquality[0m
           There are three print quality settings:


               -1   [1mdraft[0m
                0   [1mnormal[0m
                1   [1mpresentation [22mor [1mbest[0m

           The default is [1mnormal[22m.  You may specify the strings or an  integer.
           Out-of-range  numerical  values  will  generate  a  warning but are
           passed through to the printer if it is a  model  understanding  the
           PCL  command  "Print Quality".  If it isn't, the effect is the same
           as specifying [1mnormal[22m.

   [1mLooking up Compile-Time Defaults[0m
       Some default values for options can be chosen at compile time.  If  you
       later  want  to  know  these values, run [4mgs[24m on the following PostScript
       code:

           currentpagedevice
           dup /Name get (hpdj) eq not
           {
             (ERROR: You have not selected the hpdj driver.) =
           }
           {
             (Model: ) print
             dup /Model get =

             (Resolution: ) print
             dup /HWResolution get ==

             (Compression method: ) print
             dup /CompressionMethod get =

             (Margin file: ) print
             dup /MarginFile get
             dup () eq
             {pop (none)} if
             =

             (PagecountFile is ) print
             dup /PagecountFile known not
             {(not ) print} if
             (supported.) =
           } ifelse
           pop
           quit

       Note that this will not necessarily return  the  compile-time  defaults
       but  only  the  values current at the time of execution.  Therefore you
       should not specify any options except [1m-sDEVICE=hpdj [22mand, if your ghost-
       script executable has been compiled without a default model for [4mhpdj[24m or
       if you want to find out whether there  is  a  compiled-in  margin  file
       path,  [1m-sModel=unspec[22m.  You should also make sure that you have not set
       environment variables modifying ghostscript's behaviour.


[1mCONFIGURATION[0m
   [1mMargin Description File[0m
       A margin description file (margin file for short) can be used to  over-
       ride  the builtin model-specific lists of supported media sizes and the
       margins in force for each.  This feature is mainly intended to be  used
       in  conjunction  with  [1m-sModel=unspec[22m: if you have a model not directly
       supported by this driver, look up the supported page sizes  and  corre-
       sponding printable regions in your printer's manual and enter them in a
       margin file.

       [1mNote: [22mEntering a page size in the margin file which is not really  sup-
       ported  by  your printer is not useful: the PCL interpreter will simply
       ignore the request to set this page size, and printer  and  driver  may
       have diverging opinions about what the margins will be.  If you need to
       print on a medium of a size not supported by  your  printer,  choose  a
       larger  and  printer-supported  size in PostScript or via [1m-dFIXEDMEDIA[22m,
       shift the image if necessary,  establish  properly-positioned  clipping
       regions  within the real size, and print.  However, if you have a newer
       DeskJet supporting custom page sizes, this is not  necessary  (see  be-
       low).

       Margin specifications are important for two reasons: the values for the
       left and top margins determine how the  output  is  positioned  on  the
       page,  and  sufficiently  large values for the right and bottom margins
       prevent the print head being caught at the paper's  edge  and  printing
       beyond the sheet, respectively.  Because DeskJet printers often have an
       inconveniently large bottom margin (usually  0.4-0.8  inches  or  10-20
       mm),  one might be tempted to specify smaller values than listed in the
       printer's manual.  However, one user reported  that  this  led  to  the
       printer  depositing  a large wet blob of black ink at the bottom of the
       page.  Specifying a smaller margin on the right is in contrast probably
       harmless because, according to HP, DeskJet printers always clip at that
       margin.

       A line in the margin file can be blank, a comment line (first non-blank
       character is '#'), or one of the following:

           unit [4munit[0m
           [4mcode[24m  [4mleft[24m [4mbottom[24m [4mright[24m [4mtop[0m

       A  unit line specifies in which units margin specifications in the fol-
       lowing lines should be interpreted.  [4munit[24m can be either in or  mm  with
       in  being  the  default.   A  unit specification remains in force until
       overridden by a following unit line.

       The second kind of line states that the  model  supports  a  particular
       page size, identified by its PCL page size [4mcode[24m, and specifies the mar-
       gins in force for that size when printing in black, in raster  graphics
       mode, and in portrait orientation for the medium (width <= height).  Be
       careful with envelopes: older (pre-1997)  HP  documentation  frequently
       gives  their  margins  in  landscape orientation; you can check this by
       looking for the largest margin value: in portrait orientation it should
       be  at  the bottom.  The margins have to be specified as floating point
       numbers in inches or millimetres as announced  by  the  last  preceding
       unit  line.   The floating point format is that of the "C" locale.  De-
       pending on the model, [4mhpdj[24m will either assume that the same margins ap-
       ply  for  colour printing (this is the case for [1munspec[22m) or increase the
       bottom margin by a model-specific amount in that case.

       The [4mcode[24m must be one of the following  PCL  page  size  codes  (entries
       marked with an asterisk are those used by the model [1munspec [22mif no margin
       file is employed):


             *1   US Executive (7.25  10.5 in)
             *2   US Letter (8.5  11 in)
             *3   US Legal (8.5  14 in)
              6   US Tabloid (11  17 in, also called "Ledger")
             15   US Statement (5.5  8.5 in)
             16   Super B (305  487 mm)
            *24   ISO/JIS A6 (105  148 mm)

            *25   ISO/JIS A5 (148  210 mm)
            *26   ISO/JIS A4 (210  297 mm)
             27   ISO/JIS A3 (297  420 mm)
            *45   JIS B5 (182  257 mm).
                  This is distinct from ISO B5 (176  250 mm).
             46   JIS B4 (257 x 364 mm).
                  This is distinct from ISO B4 (250  353 mm).
            *71   Hagaki card (100  148 mm)
            *74   US index card 4  6 in
            *75   US index card 5  8 in
            *81   US no. 10 envelope (4.125  9.5 in).
            *90   ISO DL envelope (110  220 mm)
            *92   ISO C6 envelope (114  162 mm)
           *101   custom page size
            109   US A2 envelope (4.375  5.75 in)

       The page size code 101 (custom page size) is not  understood  by  older
       printers  and  may  be  used  in a margin file only for the models [1m540[22m,
       [1m850C[22m, [1m855C[22m, and [1munspec[22m.  In these cases you can print,  within  certain
       limits,  on arbitrarily sized media.  The driver knows these limits and
       refuses to generate a file if you exceed them.  For [1munspec[22m,  there  are
       no limits.  [4mhpdj[24m will tell the printer to expect a custom page size on-
       ly if there is no fitting discrete entry.

       Every margin file must contain at least  an  entry  which  fits  ghost-
       script's  default  page  size, usually ISO A4 or US Letter.  Only those
       sizes which are listed will be accepted by [4mhpdj[24m.

       [4mhpdj[24m is distributed with an example of a margin description file, exam-
       ple.mdf.

   [1mPostScript Configuration File[0m
       Sometimes it is desirable to execute additional PostScript commands for
       a particular file or possibly all files sent to a particular printer or
       print  queue.   With ghostscript this is easily possible because [4mgs[24m ac-
       cepts several files in the invocation and executes  them  sequentially.
       This  is  particularly appropriate for those PostScript operators which
       affect device-specific features and should therefore not  appear  in  a
       portable page description.

       The  [4mhpdj[24m  distribution  contains an example of an input filter if-hpdj
       for the BSD spooler [4mlpr(1)[24m permitting the use of a print-queue-specific
       configuration file.

   [1mCorrecting Offsets[0m
       A  margin  description file is intended to adapt [4mhpdj[24m to the difference
       in margin settings between printer models and  should  usually  contain
       "official" information, preferably taken from the model's manual.

       A  different  situation  arises if a particular printer's output is not
       properly positioned on the page even if the margin information is  cor-
       rect  for this model.  PostScript defines two arrays in the page device
       dictionary for correcting such misadjustments, both containing two num-
       bers  describing  a desired shift of the page image with respect to de-
       vice space coordinate axes but in different units.  The values  in  the
       `Margins'  array  are  interpreted  with respect to a canonical default
       resolution, the newer  `PageOffset'  array  (supported  by  ghostscript
       since  probably  gs  3.50)  is  taken to be in units of 1/72 inch ("big
       points", bp).  For [4mhpdj[24m the device coordinate  system  has  an  [4mx[24m  axis
       pointing  to the right and a [4my[24m axis pointing downwards in portrait ori-
       entation, and the canonical default resolution is the  default  resolu-
       tion chosen at compile time (see the [4mOPTIONS[24m section above).

       As  an example, assume your printer shifts its output 1 mm to the right
       and 0.5 mm upwards and the default resolution of your version  of  [4mhpdj[0m
       is 300 ppi.  Now create a file containing either the PostScript code

           << /Margins [-11.8 5.9] >> setpagedevice

       ("shift 11.8 pixels to the left and 5.9 pixels down") or

           << /PageOffset [-2.8 1.4] >> setpagedevice

       ("shift  2.8  bp  to the left and 1.4 bp down") and have it executed by
       ghostscript before the file to be printed.  If you specify  both,  Mar-
       gins and PageOffset, the total shift performed by [4mgs[24m will be the sum of
       the two.

       The file align.ps in the ghostscript distribution or  the  margin  test
       files distributed with [4mhpdj[24m can be used to determine the necessary cor-
       rection.  You should be aware that you have to expect fluctuations  be-
       tween individual print jobs, in particular in the horizontal direction.

   [1mGamma Correction[0m
       DeskJets usually produce colour prints which are too dark (too much ink
       on the page).  In this case you should perform [4mgamma[24m [4mcorrection[24m by mod-
       ifying what PostScript calls [4mtransfer[24m [4mfunctions[24m.  In the simplest case,
       create a file containing the PostScript command

           {[4mnumber[24m exp} settransfer

       where a good value for [4mnumber[24m is usually  in  the  range  0.3-0.5,  and
       specify  this  file  in  ghostscript's command line before the file you
       wish to print.  Now the intensities of all colorants will  be  rescaled
       by exponentiation with [4mnumber[24m.  Because PostScript intensity values are
       in the range zero to one with zero meaning dark and one  meaning  light
       (additive  interpretation),  a value of [4mnumber[24m < 1 will lead to lighter
       colours and [4mnumber[24m > 1 results in darker colours.

       You can also set independent transfer functions for the four  colorants
       by  using  the operator setcolortransfer which expects four routines as
       arguments.  Consult a PostScript manual if you want to learn more about
       transfer functions.

       For  a device with less than 32 intensity levels per colorant, at reso-
       lutions below 800 ppi, and unless you  explicitly  set  transfer  func-
       tions, [4mgs[24m applies a default gamma correction roughly corresponding to a
       value of 0.8 for [4mnumber[24m.

   [1mDifferent Numbers of Black and CMY Intensities[0m
       DeskJets supporting C-REt apparently achieve more than two  intensities
       per  colorant by putting a variable number of layers of the same ink on
       top of each other.  This happens during several  passes  of  the  print
       head.   The  number of levels which can be achieved is therefore deter-
       mined by the number of passes which in turn is influenced by the  print
       quality  and the media type (that is apparently the reason why using C-
       REt in draft quality is useless).  It is now likely that  if  one  uses
       more  levels  than can be supported by the number of passes, the higher
       levels will look the same.  This is what seems to happen if one  prints
       with 4 intensity levels for CMY on plain paper with a DeskJet 850C: the
       fourth level is accepted by the printer but to me  it  looks  indistin-
       guishable from the third.

       In this situation we can compensate for ghostscript not correctly deal-
       ing with different numbers of black and CMY intensity levels  by  using
       PostScript's transfer functions.  The idea is to specify in the invoca-
       tion the higher number of levels for both, black and CMY,  but  to  map
       the  range for those components where actually only a smaller number of
       levels is distinguishable to a reduced range which [4mgs[24m will divide  into
       the  required (smaller) number of intervals.  Although the printer will
       be told to expect the higher number of intensities, it will  never  re-
       ceive them.  However, if the assumptions above are correct, the highest
       level it does receive will anyway look like the highest level possible!

       For the case of 4 black and 3 intended CMY levels the  CMY  intensities
       must  be  remapped from the range [0, 1] to the range [1/3, 1].  Here's
       the code, including an equal gamma value [4mnumber[24m  for  all  four  compo-
       nents:

           {[4mnumber[24m exp 2 mul 1 add 3 div}
           dup dup
           {[4mnumber[24m exp}
           setcolortransfer

       In  the  call  to [4mgs[24m you must now specify a value of 4 for both, [1mBlack-[0m
       [1mLevels [22mand [1mCMYLevels[22m.

   [1mHalftoning[0m
       Most printers offer only a small number of intensities per colorant and
       pixel.   In  order to generate a larger range of colours, one therefore
       employs [4mhalftoning[24m which consists of  dividing  the  pixel  array  into
       [4mhalftone[24m  [4mcells[24m, each of which represents one effective pixel which can
       now display more shades.  This method trades resolution for the  number
       of shades and applies to all structures which have to be painted with a
       colour which cannot be represented exactly.  At 300 ppi and with a  bi-
       level  device  a  typical choice is to use halftone cells of 55 pixels
       leading to an effective resolution of 60 ppi and 26 shades  per  compo-
       nent.  These are also ghostscript's default values at 300 ppi.

       Which kind of halftoning is appropriate depends not only on the printer
       but also on the document to be printed.  For this reason PostScript of-
       fers  access to the halftoning parameters.  You should use this feature
       in particular if your printer supports more than two  intensity  levels
       because ghostscript does not recognize by itself that it can now obtain
       a higher effective resolution without a loss in the number  of  shades.
       However,  should  your printer support at least 32 intensity levels you
       need not bother about this point because in that  case  [4mhpdj[24m  will  not
       cause halftoning to be used.

       For  those  not  familiar with PostScript, here's some code to redefine
       ghostscript's default halftoning state for non-monochrome colour  modes
       to  use an array of halftone cells with a resolution of [4mfrequency[24m cells
       per inch (hence the resolution divided by [4mfrequency[24m is the size of  the
       halftone cells in pixels):

           currenthalftone dup /HalftoneType get 2 eq
           {
             begin
               /RedFrequency   [4mfrequency[24m def
               /GreenFrequency [4mfrequency[24m def
               /BlueFrequency  [4mfrequency[24m def
               /GrayFrequency  [4mfrequency[24m def
               currentdict
             end
             sethalftone
           }
           {pop}  % Not prepared for this case.
           ifelse

       For  general  applications,  reasonable values for [4mfrequency[24m on a 3- or
       4-level device at 300 ppi are 75 and 100.  You can use the file  color-
       cir.ps  in  the ghostscript distribution to gain some impression of the
       effects on the size of halftone cells and the number of shades you  can
       distinguish.   Consult  a  PostScript  manual if you want to learn more
       about how to specify halftones.

       If you are using the colour mode [1mCMYK [22mand more than 2 black levels  you
       should  not set merely a single halftone screen (setscreen, a type-1 or
       a type-3 halftone dictionary) because ghostscript's  dithering  routine
       can in this case return non-monotonic levels of black for monotonic in-
       put intensities.  However, if you specify independent halftone informa-
       tion  for the colour components, [4mgs[24m uses a slower but more accurate al-
       gorithm instead which does not lead to the wrong behaviour.  It is  not
       necessary  for  the  halftone information to be different for different
       components to achieve this.  Note that  ghostscript  installs  separate
       halftone  screens  for  CMYK devices by default if the resolution is at
       least 150 ppi.


[1mLIMITATIONS[0m
   [1mGhostscript Version[0m
       This manual page contains statements relying on  undocumented  features
       of  ghostscript.   These statements are to my best knowledge and belief
       correct for at least ghostscript 5.50, and I hope I've not missed  sig-
       nificant  deviations  when testing with older versions.  But I can't of
       course guarantee anything for newer ones.

   [1mThe Rendering Algorithm[0m
       In ghostscript's internal architecture the ghostscript kernel calls  on
       a  device driver for basic drawing operations and to ship out completed
       pages.  For most if not all print devices this process can be separated
       into rendering in memory and transferring the resulting array of pixels
       to a file or directly to a printer.

       Ghostscript has an abstract printer device ([4mprn[24m) which uses a  "memory"
       or "command list" device for rendering and transfers the completed page
       to a printer-specific backend for output.  Such a backend  must  supply
       several  parameters  for  the rendering process but its main purpose is
       the conversion from ghostscript's internal pixel data  structure  to  a
       printer-specific  format.   [4mhpdj[24m  is  such a [4mprn[24m-derived backend.  This
       means in particular that [4mhpdj[24m does not have much influence on the  ren-
       dering  but also that a user can influence the rendering process by the
       usual methods available in PostScript.

       I do not claim that this leaves nothing to be  desired.   For  example,
       there  is no possibility in this implementation to perform Floyd-Stein-
       berg dithering.  Of course, one can  implement  error  diffusion  in  a
       ghostscript device driver and a number of people have done so in print-
       er-specific backends.  I do not believe, though, that such an implemen-
       tation  belongs  there:  it should better be implemented in an improved
       rendering device.  In that way, it could be used for other printer-spe-
       cific backends as well.  This is also true for every other kind of mod-
       ification of the rendering process.  I have therefore deliberately  re-
       stricted [4mhpdj[24m to be a "purely printing" backend: it knows about PCL but
       not about rendering.

       Therefore, if you need better visual quality for documents with  shades
       of  grey  or non-primary (non-CMYK) colours, this cannot be achieved by
       giving some tricky combination of option values to [4mhpdj[24m.   Instead  you
       should experiment with the relevant PostScript operators (see chapter 6
       of the [4mPostScript[24m [4mLanguage[24m  [4mReference[24m),  or  ultimately  extend  ghost-
       script's [4mprn[24m device.

   [1mThe Configure Raster Data Command[0m
       There  is a new PCL-3+ command called "Configure Raster Data" for which
       until recently I had not been able to obtain documentation.  This  com-
       mand is apparently the basis for supporting unequal resolutions in hor-
       izontal and vertical directions and for HP's Color Resolution  Enhance-
       ment  technology (C-REt).  Some option values supported by [4mhpdj[24m lead to
       Configure Raster Data being used and [1mmust therefore be  considered  un-[0m
       [1msafe![0m

       At  least some of the series-500 DeskJets as well as newer models claim
       to permit unequal resolutions in horizontal and vertical directions, in
       particular  600    300 ppi.  The corresponding implementation in [4mhpdj[24m,
       available only for the model [1munspec[22m, is based on Configure Raster Data.
       It  seems  to  work at least for the DeskJet 690C; it does not work for
       the DeskJet 870C (see below).  I would however strongly advise  against
       using  these  resolutions for printing on a series-500 DeskJet because,
       although these models have a 600 dpi addressable horizontal  resolution
       grid  they  do  not permit neighbouring pixels to be activated (and the
       dots printed still have a diameter of about 1/300 in).  The raster data
       generated  by  [4mgs[24m  does  not obey this restriction.  In addition, it is
       likely that the higher resolution is  anyway  only  supported  for  the
       printer's builtin fonts and not for general raster data.

       Concerning  the  DeskJet  870C,  my impression is that although some HP
       documents and drivers use expressions like "600x300  dpi  C-REt  color"
       for this printer, the model does not really support a resolution of 600
        300 ppi.  First, it does not accept [4mhpdj[24m's output with  this  resolu-
       tion,  and  second,  if  one  redirects the best output of HP's Windows
       driver for this printer to a file, the result is a file with what  I've
       called a mixed resolution, i.e., 600 ppi for black and 300 ppi for CMY.
       To me it looks therefore as if Hewlett-Packard has been sloppy in  for-
       mulating its documentation.

       I  am not quite certain what HP means by C-REt or PhotoREt but it seems
       to be a combination of hardware  functionality  and  properties  of  HP
       printer  drivers.   The hardware part makes it possible to specify more
       than the two basic intensities, on or off, per colorant and pixel.   As
       far as I know, this capability is only available in series-800 DeskJets
       and it has to be accessed by Configure Raster Data.  The implementation
       of  non-default  values for [4mhpdj[24m's options [1mBlackLevels [22mand [1mCMYLevels [22mis
       therefore based on Configure Raster Data.  It works at least  with  the
       DeskJets 850C, 870C and 890C.

   [1mPerformance for Larger Numbers of Intensity Levels[0m
       This  could be improved by replacing some generic routines by more spe-
       cialized ones for particular parameter values.   There  does  not  seem
       much  sense  in doing this, though, until I know that the code in ques-
       tion is needed for some printer model.

   [1mMixed Resolutions[0m
       Newer DeskJets are able to print with different resolutions  for  black
       and CMY on the same region of a page.  For example, the best quality on
       a DeskJet 850C is achieved with 600 ppi for black and 300 ppi for  CMY.
       This  is  also  due to the new Configure Raster Data command and is not
       supported.  I suspect that implementing this really well in ghostscript
       is  not  a  simple task and probably requires modifying the ghostscript
       kernel.

   [1mPhoto Cartridges[0m
       From what I've heard, DeskJet printers with photo cartridges  installed
       do not use a CMYK palette but instead one with 6 components.  I have no
       official information on this interface and ghostscript  currently  does
       not support `DeviceN' as a native colour space.

   [1mCartridge Alignment[0m
       DeskJet printers with more than one ink cartridge present should usual-
       ly be configured for the proper relative alignment of these cartridges.
       Apparently, this information is stored in not-immediately-volatile mem-
       ory in the printer together with some default settings like the default
       media  size which are not relevant for printing with [4mhpdj[24m.  As I do not
       have information on how this is done, you will need to use one of  HP's
       programs for this purpose.

       On  a Linux system, try installing and running HP's DOS DeskJet control
       panel DJCP in the DOS emulator.  I did not get  it  to  work,  but  you
       might  have more luck (or skill).  DJCP should be present on one of the
       installation media you received with your printer.


[1mFUTURE DIRECTIONS[0m
       I intend to release a new version in a few months for which I am  going
       to change the name of the driver from [4mhpdj[24m to (probably) [4mpcl3[24m.  The new
       name will more accurately reflect what this driver is for.

       This new version will be based on more extensive HP documentation, will
       therefore  support more printers, and it will add some new functionali-
       ty.


[1mKNOWN BUGS[0m
       There are no known bugs in [4mhpdj[24m proper, but there do exist restrictions
       or  bugs  in  [4mgs[24m  which can lead to faulty behaviour when printing with
       [4mhpdj[24m.  As far as I noticed them they are mentioned in the body of  this
       manual page at the relevant points.


[1mSEE ALSO[0m
       gs(1)

       Adobe Systems
       [4mPostScript[24m [4mLanguage[24m [4mReference[0m
       Third edition, 1999.

       [4mA[24m [4mFirst[24m [4mGuide[24m [4mto[24m [4mPostScript[0m
       http://www.cs.indiana.edu/docproject/programming/postscript/-
       postscript.html

       Hewlett-Packard
       [4mTechnical[24m [4mReference[24m [4mGuide[24m [4mfor[24m [4mthe[24m [4mHP[24m [4mDeskJet[24m [4m500[24m [4mSeries[24m [4mPrinters[0m
       First edition, October 1994. Manual Part Number: C2170-90099.

         Unfortunately, this guide does not describe all  valid  commands.   I
         was  told  in October 1997 by the German firm distributing HP manuals
         that there is no newer HP manual on PCL 3 and that they had even con-
         sidered writing one themselves for this reason.


[1mAUTHOR[0m
       Copyright   1996, 1997, 1998, 1999 by Martin Lottermoser, Metzgerfeld-
       weg 9, 85737 Ismaning, Germany.
       E-mail: martin.lottermoser@mch20.sbs.de.

       This is free software, released under the terms of the GNU Library Gen-
       eral Public License (LGPL), Version 2.  [1mUSE IT AT YOUR OWN RISK.[0m

       [4mhpdj[24m  has  a  home  page at ftp://ftp.sbs.de/pub/graphics/ghostscript/-
       pcl3/pcl3.html.  The source code for the driver  is  available  in  the
       same directory, file hpdj-[4mversion[24m.tar.gz.  You should, however, keep in
       mind that the name of the driver will change in the future (see  [4mFUTURE[0m
       [4mDIRECTIONS[24m) and this will of course be reflected in the names of files.



hpdj 2.6                          1999-10-16                        GS-HPDJ(1)
