== Ghostscript Raster Printing (a.k.a. Using Ghostscript as a Printer Driver) == Ghostscript includes a not-insignificant number of built-in printer drivers, many of which are not otherwise supported by OS/2 or CUPS. Normally, 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). However, there is a way to print seamlessly to Ghostscript-supported printers, if some special configuration is used. Doing it this way bypasses foomatic-rip (and, strictly speaking, CUPS itself) entirely. Most 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. [[br]][[br]] == Basic Procedure == The Epson Ghostscript drivers discussed by Dmitry (below) are now included in Paul Smedley's distribution of Ghostscript, as of version 9.00, and also as an update to version 8.71 (included in the WPI distribution). This technique describes how to send the print job directly from the application --> Ghostscript --> printer without having to go through the intermediate stage of running GSView. Basically, this is made possible using the new [http://svn.netlabs.org/unipdr UNI.PDR] universal port driver: * Install UNI.PDR (to \OS2\DLL) * Create a new port of type UNI. * Edit the port properties. We need to send the print job through two programs: Ghostscript, followed by whatever command actually sends the job to the printer. Unfortunately, UNI.PDR doesn't currently support piping the job through multiple programs, so you have to use a REXX script or similar to link the programs together. The 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 network printers, for parallel/serial ports, and for USB connections. [[br]][[br]] === Printing to a Network Printer === I've used the following script to print to a TCP/IP (LPD) printer on the network: {{{ /* GS2LPR.CMD - print to a TCP/IP printer through !GhostScript, using LPR. * * The top-level GhostScript directory should be set in the environment * variable GHOSTSCRIPT (or just edit the path directly in the file, below). * * Syntax: GS2LPR %file% */ CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs' CALL SysLoadFuncs PARSE ARG model server printer jobfile IF jobfile == '' THEN RETURN 1 logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT') tmpdir = VALUE('TMP',,'OS2ENVIRONMENT') gspath = VALUE('GHOSTSCRIPT',,'OS2ENVIRONMENT') IF gspath == '' THEN gspath = 'f:\gs\gs9.00' IF logdir == '' THEN logdir = tmpdir logfile = logdir'\gs2lpr.log' tmpfile = SysTempFileName( tmpdir'\GS_?????.TMP', '?') gscmd = gspath'\bin\gsos2.exe -sDEVICE='model '-dBATCH -dNOPAUSE -sOUTPUTFILE='tmpfile' -q' jobfile lprcmd = 'lpr.exe -a 0 -b -s' server '-p' printer tmpfile '@echo off' IF STREAM( logfile, 'C', 'QUERY EXISTS') <> '' THEN CALL SysFileDelete logfile CALL LINEOUT logfile, 'Running GhostScript with command line' gscmd CALL LINEOUT logfile ADDRESS CMD gscmd '2>&1 >>'logfile CALL LINEOUT logfile, 'Return code:' rc CALL LINEOUT logfile, '' CALL LINEOUT logfile, 'Printing job with command line' lprcmd CALL LINEOUT logfile ADDRESS CMD lprcmd '2>&1 >>' logfile CALL LINEOUT logfile, 'Return code:' rc CALL LINEOUT logfile, '' CALL SysFileDelete tmpfile RETURN 0 }}} 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: ||=''Path and file'' =||{{{cmd.exe}}} || ||=''Parameters'' =||{{{/c c:\os2\gs2lpr.cmd lp9400 192.168.1.100 * %file%}}} || You could presumably print to a Samba printer by using {{{smbspool}}} instead of {{{lpr}}}. (''Don't'' try to print through CUPS -- i.e. with {{{cupslpr}}} -- using this technique, because the job will already be in printer-specific format at that point; CUPS expects to receive Postscript input, and will choke as a result. In any case, you're presumably using this technique because printing via CUPS doesn't work in the first place.) [[br]][[br]] === Printing to a Local Parallel or Serial Attached Printer === It's presumably possible to print to a local (LPT/COM) printer using the OS/2 'print' command via the following script, but this has ''not'' been tested. {{{ /* GS2PORT.CMD - print to a parallel/serial attached printer through * GhostScript, using PRINT. * * The top-level GhostScript directory should be set in the environment * variable GHOSTSCRIPT (or just edit the path directly in the file, below). * * Syntax: GS2PORT %file% */ PARSE ARG model port jobfile IF jobfile == '' THEN RETURN 1 logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT') tmpdir = VALUE('TMP',,'OS2ENVIRONMENT') gspath = VALUE('GHOSTSCRIPT',,'OS2ENVIRONMENT') IF gspath == '' THEN gspath = 'f:\gs\gs8.71' IF logdir == '' THEN logdir = tmpdir logfile = logdir'\gs2port.log' tmpfile = SysTempFileName( tmpdir'\GS_?????.TMP', '?') gscmd = gspath'\bin\gsos2.exe -sDEVICE='model '-dBATCH -dNOPAUSE -sOUTPUTFILE='tmpfile' -q' jobfile lprcmd = 'print' tmpfile '/D:'port '@echo off' IF STREAM( logfile, 'C', 'QUERY EXISTS') <> '' THEN CALL SysFileDelete logfile CALL LINEOUT logfile, 'Running GhostScript with command line' gscmd CALL LINEOUT logfile ADDRESS CMD gscmd '2>&1 >>'logfile CALL LINEOUT logfile, 'Return code:' rc CALL LINEOUT logfile, '' CALL LINEOUT logfile, 'Printing job with command line' lprcmd CALL LINEOUT logfile ADDRESS CMD lprcmd '2>&1 >>' logfile CALL LINEOUT logfile, 'Return code:' rc CALL LINEOUT logfile, '' CALL SysFileDelete tmpfile RETURN 0 }}} In this case the UNI port settings for a printer on LPT1 would be: ||=''Path and file '' =|| {{{cmd.exe}}} || ||=''Parameters '' =|| {{{/c c:\os2\gs2port.cmd lp9400 lpt1 %file%}}} || [[br]][[br]] === Printing to a Local USB Attached Printer === 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. First of all, the UNI port settings for the printer object look something like: ||=''Path and file'' =|| {{{cmd.exe}}} || ||=''Parameters'' =|| {{{/c c:\os2\gs2q.cmd lp9400 LP-9400-Raw %file%}}} || 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. The script in this case looks like: {{{ /* GS2Q.CMD - print to an IBMNULL print queue using GhostScript. This * requires VROBJ.DLL to be installed. * * The top-level GhostScript directory should be set in the environment * variable GHOSTSCRIPT (or just edit the path directly in the file, below). * * Syntax: GS2Q %file% */ CALL RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs' CALL SysLoadFuncs CALL RxFuncAdd 'VRPrintFile', 'VROBJ.DLL', 'VRPrintFile' CALL RxFuncAdd 'VRError', 'VROBJ.DLL', 'VRError' PARSE ARG model printer jobfile IF jobfile == '' THEN RETURN 1 logdir = VALUE('LOGFILES',,'OS2ENVIRONMENT') tmpdir = VALUE('TMP',,'OS2ENVIRONMENT') gspath = VALUE('GHOSTSCRIPT',,'OS2ENVIRONMENT') IF gspath == '' THEN gspath = 'f:\gs\gs8.71' IF logdir == '' THEN logdir = tmpdir logfile = logdir'\gs2q.log' tmpfile = SysTempFileName( tmpdir'\GS_?????.TMP', '?') gscmd = gspath'\bin\gsos2.exe -sDEVICE='model '-dBATCH -dNOPAUSE -sOUTPUTFILE='tmpfile' -q' jobfile '@echo off' IF STREAM( logfile, 'C', 'QUERY EXISTS') <> '' THEN CALL SysFileDelete logfile CALL LINEOUT logfile, 'Running GhostScript with command line' gscmd CALL LINEOUT logfile ADDRESS CMD gscmd '2>&1 >>'logfile CALL LINEOUT logfile, 'Return code:' rc CALL LINEOUT logfile, '' CALL LINEOUT logfile, 'Now sending file to printer' printer rc = VRPrintFile( printer, tmpfile ) CALL LINEOUT logfile, 'Return code:' rc IF rc == 0 THEN call lineout logfile, VRError() CALL LINEOUT logfile, '' CALL SysFileDelete tmpfile RETURN 0 }}} 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). Note that this script as shown doesn't accept blanks in the printer name, so you should name your IBMNULL printer accordingly. [[br]][[br]] ---- == Original Note == The original posting from Dmitry Froloff follows. This is mainly for historical interest now. ===== List of newly supported Epson printers: ===== epl2050 epl2050p epl2120 epl2500 epl2750 epl5800 epl5900 epl6100 epl6200 lp1800 lp1900 lp2200 lp2400 lp2500 lp7500 lp7700 lp7900 lp8100 lp8300f lp8400f lp8600 lp8600f lp8700 lp8900 lp9000b lp9100 lp9200b lp9300 lp9400 lp9600 lp9600s alc1900 alc2000 alc4000 alc4100 alc8500 alc8600 alc9100 lp3000c lp8000c lp8200c lp8300c lp8500c lp8800c lp9000c lp9200c lp9500c lp9800c Why I made this build. Our company bought Epson AcuLaser C1900 color printer. This model is capable to work PCL5 mode but in B/W mode only and doesn't understand poscript., while I wish to print in color too. So I look for solution and found out that Epson sources are GPL now and exist as GS patch. So I downloaded the latest GS (8.53 at the moment) and the latest Epson GS patch ghostscript-7.07.tar.bz2. I applied the patch (patched sources GS doesn't changed too much from 7.07 to 8.53 version) and built the modules with gcc 3.3.5, what mean that you need lib06 dll (you may take it here ). I also made some minor changes in main GS code to finish new printer support with OS/2 printing subsystem. If You wish to print from GSView You'll need to need to make some changes in gsview printer.ini file. I'm not familar with it's grammar, so for my printer I simply add line in [Devices] section: alc1900=1200x1200,600x600,300x300 I also create a new printer object with IBM NULL printer driver. May be there is no need to do this as GS send data to printer queue in raw mode? Now I'm capable to print pdf and ps files from GSView. To finish printer support to other OS/2 application I installed fake printer object which generate ps file. Now I print to this fake printer and it generate ps file. After that I simply print this ps file from GSView. This may be automated as well, as I'm at the beginning of the whole way Unfortunatelly, I didn't find the universal solution for all aplication. For example, I use ScenicSoft postscript color printer driver (imported with PPD file) in 2400 resolution for printing from OpenOffice and Xerox 4900 postscript printer driver for printing from Mozilla (works fine only in 300dpi mode :\ ) What's the next? I can add the same way most of HP printers support. It operate slightly different - via separate application named ijs server. I already built the server itself, so everything depend on your backward requests :) -- Best regards. Dmitry.