Changes between Version 6 and Version 7 of GhostScriptRasterPrinting


Ignore:
Timestamp:
Apr 10, 2012, 12:29:25 PM (12 years ago)
Author:
Alex Taylor
Comment:

Change USB instructions to use EPRINT; added summary step-by-step instructions.

Legend:

Unmodified
Added
Removed
Modified
  • GhostScriptRasterPrinting

    v6 v7  
    11== Ghostscript Raster Printing (a.k.a. Using Ghostscript as a Printer Driver) ==
    22
    3 Ghostscript includes a not-insignificant number of built-in printer drivers, many of which are not otherwise supported by OS/2 or CUPS.
     3Ghostscript includes a large number of built-in printer drivers, many of which are not otherwise supported by OS/2 or CUPS.
    44
    55Normally, the way CUPS supports such printers is by calling a program called foomatic-rip which validates the incoming postscript print job, adds some extra options to it, and then calls Ghostscript with the predetermined parameters.  Unfortunately, this doesn't currently work under OS/2 because foomatic-rip seems to dislike the postscript data generated by the OS/2 printer drivers (ECUPS.DRV, PSCRIPT.DRV, etc).
     
    99Most of the discussion below focuses on the printers in the Epson driver collection for Ghostscript, but it should work equally well for any built-in Ghostscript printer driver.
    1010[[br]][[br]]
     11
    1112
    1213== Basic Procedure ==
     
    2223The details of this REXX script depend on what kind of printer connection you have.  The program that actually sends the data to the printer is going to be different for LPD vs. SMB network printers, and different again for local USB connections.
    2324
    24 [[br]][[br]]
     25Two REXX scripts are attached here (see the attachments section at the bottom of this page). 
     26 * GS2PORT.CMD is for printing to a locally-attached printer on a USB or parallel port (or some other port type).  This script requires the EPRINT.EXE utility (also attached).
     27 * GS2LPR.CMD is for printing to a TCP/IP network printer using the LPR/LPD protocol.
     28
     29==== Quick Instructions ====
     30
     31 1. Make sure you have Ghostscript v8.71 with [http://download.smedley.info/gsdll2.zip the updated DLL] installed and working.
     32 2. Download the [http://svn.netlabs.org/unipdr UNI.PDR] port driver and copy UNI.PDR to \OS2\DLL.
     33 3. Download [http://www.altsan.org/os2/printing/#eprint EPRINT] and place the executable somewhere in your path.
     34 4. Get {{{GS2LPR.CMD}}} (for TCP/IP printers) and/or {{{GS2PORT.CMD}}} (for USB and other local printers) from this page and place them somewhere convenient (these instructions will assume they are in your \OS2 directory).
     35 5. Create your printer object in the WPS.
     36 6. Open the printer object properties notebook, go to the '''Output port''' page, click on ''Install new port'' and select 'UNI'.  (If you don't see 'UNI' listed, select 'New port drivers', enter the path to \OS2\DLL and click on ''Refresh''.)
     37 7. Edit the properties of the new UNI''*'' port as follows:
     38   * ''Path and file'': {{{cmd.exe}}}
     39   * ''Parameters'':
     40      * For TCP/IP (LPR) printers: {{{/c}}} ''x''{{{:\os2\gs2lpr.cmd}}} ''<model>'' ''<IP address>'' ''<queue name>'' {{{%file%}}}
     41      * For local printers: {{{/c}}} ''x''{{{:\os2\gs2lpr.cmd}}} ''<model>'' ''<port name>'' {{{%file%}}}
     42
     43The parameters do not include '<' and '>'.  For TCP/IP printers, if there is no queue name then use '*' as the queue.  For local printers, if you don't know the port name then use {{{EPRINT /L}}} to get a list of ports.
     44
     45This procedure is described in more detail below.
     46
     47'''Note:''' You should use Ghostscript version 8.71.  Later versions (9.''x'') do not work reliably.
     48
     49
     50[[br]][[br]]
     51
    2552
    2653=== Printing to a Network Printer ===
     
    2956
    3057{{{
    31 /* GS2LPR.CMD - print to a TCP/IP printer through !GhostScript, using LPR.
     58/* GS2LPR.CMD - print to a TCP/IP printer through Ghostscript, using LPR.
    3259 *
    3360 * The top-level GhostScript directory should be set in the environment
     
    76103}}}
    77104
    78 Using the above, the following [http://svn.netlabs.org/unipdr UNI.PDR] settings will allow printing to a networked LP-9400 printer with TCP/IP address 192.168.1.100:
     105Using the above, the following [http://svn.netlabs.org/unipdr UNI.PDR] settings will allow printing to a networked Epson LP-9400 printer with TCP/IP address 192.168.1.100:
    79106
    80107 ||=''Path and file'' =||{{{cmd.exe}}} ||
    81108 ||=''Parameters''    =||{{{/c c:\os2\gs2lpr.cmd lp9400 192.168.1.100 * %file%}}} ||
     109
     110The '*' is used for the LPR queue name in the event that no explicit queue name is needed (this is generally the case when the printer itself is acting as the print server).
    82111
    83112You could presumably print to a Samba printer by using {{{smbspool}}} instead of {{{lpr}}}. 
     
    100129=== Printing to a Local USB Attached Printer ===
    101130
    102 Unfortunately, the OS/2 `PRINT` command doesn't work with USB ports.  The only solution which I've found that works with USB printers is the following, rather convoluted procedure.
    103 
    104 First of all, the UNI port settings for the printer object look something like:
     131Unfortunately, the OS/2 `PRINT` command doesn't work with USB ports.  There are a couple of ways around this, but the best solution available (at the moment) is to use the EPRINT utility, available at http://www.altsan.org/os2/printing/#eprint (it should also be attached to this page).
     132
     133Using this method, the UNI port settings for the printer object look something like:
    105134||=''Path and file'' =|| {{{cmd.exe}}} ||
    106 ||=''Parameters''    =|| {{{/c c:\os2\gs2q.cmd lp9400 LP-9400-Raw %file%}}} ||
    107 
    108 Next, it's necessary to create a ''second'' printer object (in this example called "LP-9400-Raw") which prints to the actual USB port.  However, this second printer must use the IBMNULL printer driver with the spool file format set to PM_Q_RAW.
     135||=''Parameters''    =|| {{{/c c:\os2\gs2port.cmd lp9400 EPSON_LP_9400_1 %file%}}} ||
     136
     137Here, ''EPSON_LP_9400_1'' is the name of the USB port that OS/2 creates when the printer is plugged in to the computer.  (You can find out what the correct port name is by using the {{{EPRINT /L}}} command, which lists all ports in the system.) 
    109138
    110139The script in this case looks like:
    111140{{{
    112 /* GS2Q.CMD - print to an IBMNULL print queue using GhostScript.  This
    113  * requires VROBJ.DLL to be installed.
     141/* GS2PORT.CMD - print to a locally-attached printer through Ghostscript, using
     142 * EPRINT.
    114143 *
    115144 * The top-level GhostScript directory should be set in the environment
    116145 * variable GHOSTSCRIPT (or just edit the path directly in the file, below).
    117146 *
    118  * Syntax: GS2Q <model> <port> %file%
    119 */
    120 CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
    121 CALL SysLoadFuncs
    122 CALL RxFuncAdd 'VRPrintFile', 'VROBJ.DLL', 'VRPrintFile'
    123 CALL RxFuncAdd 'VRError', 'VROBJ.DLL', 'VRError'
    124 
    125 PARSE ARG model printer jobfile
     147 * Syntax: GS2PORT <model> <port name> %file%
     148 */*/
     149PARSE ARG model port jobfile
    126150IF jobfile == '' THEN RETURN 1
    127151
     
    132156
    133157IF logdir == '' THEN logdir = tmpdir
    134 logfile = logdir'\gs2q.log'
     158logfile = logdir'\gs2port.log'
    135159tmpfile = SysTempFileName( tmpdir'\GS_?????.TMP', '?')
    136160
    137161gscmd  = gspath'\bin\gsos2.exe -sDEVICE='model '-dBATCH -dNOPAUSE -sOUTPUTFILE='tmpfile' -q' jobfile
     162lprcmd = 'eprint' tmpfile '/D:'port
    138163
    139164'@echo off'
     
    145170CALL LINEOUT logfile, ''
    146171
    147 CALL LINEOUT logfile, 'Now sending file to printer' printer
    148 rc = VRPrintFile( printer, tmpfile )
    149 CALL LINEOUT logfile, 'Return code:' rc
    150 IF rc == 0 THEN
    151     call lineout logfile, VRError()
     172CALL LINEOUT logfile, 'Printing job with command line' lprcmd
     173CALL LINEOUT logfile
     174ADDRESS CMD lprcmd '2>&1 >>' logfile
     175CALL LINEOUT logfile, 'Return code:' rc
    152176CALL LINEOUT logfile, ''
    153177
     
    157181}}}
    158182
    159 This seems to work here, although I had problems until I made sure to use Ghostscript 8.71 (instead of 9.0''x'').  It also appears to be very important that the "default spool file type" in the IBMNULL printer driver properties is set to use PM_Q_RAW (and ''not'' PM_Q_STD).
    160 
    161 Note that this script as shown doesn't accept blanks in the printer name, so you should name your IBMNULL printer accordingly.
    162 [[br]][[br]]
    163 
     183[[br]][[br]]
    164184
    165185----