How to print Postscript data and ASCII text under OpenVMS on HP PCL3 network printers Date: 22-DEC-2004 Version: 1.1 Author: Michael Monscheuer, Monscheuer [at] hdw.de This document describes how to print Postscript data and ASCII text on more recent HP PCL3 deskjet and PSC series printers equiped with a network interface from an OpenVMS host. The setup for printing plain text files takes care of the printer's basic country specific character sets. The descriptions in this document preclude the reader knows VMS and DCL. SW Prerequisites: - Ghostscript - some additional libraries - standard fonts for ghostscript - MMS or MMK (the examples below refer to MMK) - The Printer driver (gdevcd8.c, provided as a seperate file) ============================================================================== Step 1: You need a unix-like "MAKE" utility to build Ghostscript. If you don't have MMS or MMK, first install MMS on your system. If you don't have access to MMS or a license for it, get a copy of MMK at http://www.madgoat.com Follow the instructions given there to build and install MMK on your OpenVMS system. ============================================================================== Step 2: Fetch a copy of AFPL Ghostscript at http://www.cs.wisc.edu/~ghost/doc/AFPL As of December, 2004, Ghostscript 8.13 was tested successfully on Alpha and Ghostscript 7.04 was tested successfully on VAX. Versions later than 7.04 won't compile on VAX due to a change for 64bit. Also, download the JPEG, PNG, and Z libraries as well as the basic font files now (offered on the same webpage). This stuff is mandatory. Follow the instructions given there how to unpack Ghostscript, the libraries and the fonts on your OpenVMS system. Put the fonts into the [.fonts] subdirectory of your Ghostscript directory. Put the libraries into directories parallel to your Ghostscript directory. Do NOT start building Ghostscript now. Read on... ============================================================================== Step 3: Copy the gdevcd8.c file you find provided with these instructions to the [GHOSTSCRIPT-x_nn.SRC] directory. 'x_nn' has to be replaced with the version number of your Ghostscript copy. ============================================================================== Step 4: Change the following files: [GHOSTSCRIPT-x_nn.SRC]OPENVMS.MMK [GHOSTSCRIPT-x_nn.SRC]CONTRIB.MAK Edit [GHOSTSCRIPT-x_nn.SRC]OPENVMS.MMK and find the section beginning with # ------ Devices and features ------ # Add the chp2200 driver to the device list. The following is an example only (but known to be working). Feel free to put it into the device list elsewhere: DEVICE_DEVS=$(DD)x11.dev $(DD)x11alpha.dev $(DD)x11cmyk.dev .... DEVICE_DEVS1= DEVICE_DEVS2=$(DD)chp2200.dev DEVICE_DEVS3=$(DD)deskjet.dev $(DD)djet500.dev $(DD)laserjet.dev .... In this file also find: JSRCDIR, PSRCDIR and ZSRCDIR Ensure the definitions point at the correct directories where the related libraries are resident. For instance PSRCDIR=[-.libpng-1_2_1] Edit [GHOSTSCRIPT-x_nn.SRC]CONTRIB.MAK Goto to this file's bottom and insert the following lines: ---8<------------------------------------------------------------------------- ### -------------- cdj850 - HP 850c Driver under development ------------- ### cdeskjet8_=$(GLOBJ)gdevcd8.$(OBJ) $(HPPCL) # Author: Uli Wortmann (uliw@erdw.ethz.ch), Martin Gerbershagen # Printer: HP 670 $(DD)cdj670.dev : $(cdeskjet8_) $(DD)page.dev $(SETPDEV2) $(DD)cdj670 $(cdeskjet8_) # Author: Uli Wortmann (uliw@erdw.ethz.ch) # Printer: HP 850 $(DD)cdj850.dev : $(cdeskjet8_) $(DD)page.dev $(SETPDEV2) $(DD)cdj850 $(cdeskjet8_) # Author: Uli Wortmann (uliw@erdw.ethz.ch), Martin Gerbershagen # Printer: HP 890 $(DD)cdj890.dev : $(cdeskjet8_) $(DD)page.dev $(SETPDEV2) $(DD)cdj890 $(cdeskjet8_) # Author: Uli Wortmann (uliw@erdw.ethz.ch), Martin Gerbershagen # Printer: HP 1600 $(DD)cdj1600.dev : $(cdeskjet8_) $(DD)page.dev $(SETPDEV2) $(DD)cdj1600 $(cdeskjet8_) $(GLOBJ)gdevcd8.$(OBJ) : $(GLSRC)gdevcd8.c $(PDEVH) $(math__h)\ $(gsparam_h) $(gxlum_h) $(gdevpcl_h) $(GLCC) $(GLO_)gdevcd8.$(OBJ) $(C_) $(GLSRC)gdevcd8.c ### -------------- cdj880 - HP 880c Driver under development ------------- ### ### Since this driver is in the development phase it is not distributed ### ### with Ghostscript, but is available from ### ### http://www.proaxis.com/~mgelhaus/linux/software/hp880c/hp880c.html ### ### NOTE: Depends on the presence of the cdj850 section above. ### # Author: Matthew Gelhaus (mgelhaus@proaxis.com) # Printer: HP 880c $(DD)cdj880.dev : $(cdeskjet8_) $(DD)page.dev $(SETPDEV2) $(DD)cdj880 $(cdeskjet8_) $(DD)chp2200.dev : $(cdeskjet8_) $(DD)page.dev $(SETPDEV2) $(DD)chp2200 $(cdeskjet8_) ---8<------------------------------------------------------------------------- Step 5: Build Ghostscript: $ SET DEF [GHOSTSCRIPT-x_nn] $ MMK/DESCRIPT=[.SRC]OPENVMS.MMK This will take some time (or some more time). While Ghostscript is being built, take the further steps. Add the required definitions for logical names to your system startup file: $ DEFINE/SYSTEM/NOLOG GS_DOC MYDISK:[GHOSTSCRIPT-x_nn.DOC] $ DEFINE/SYSTEM/NOLOG GS_LIB MYDISK:[GHOSTSCRIPT-x_nn.LIB], - MYDISK:[GHOSTSCRIPT-x_nn.FONTS] Execute these commands from the command line to have the definitions take effect immediately. Define a foreign command for the Ghostscript application, for instance: $ GHO*STSCRIPT :== $MYDISK:[GHOSTCRIPT-x_nn]GS.EXE Do not forget to add the latter to either your personal or a system wide login procedure. ============================================================================== Step 6: Set up a queue for printing plain ASCII text files (DECMCS character set). Depending upon the paper format being used, it may be necessary to modify the form's definition. The following example matches the A4 paper size on a HP PSC2510. $ DEFINE /FORM PSC 11 - /LENGTH=63 - /MARGIN=( - BOTTOM = 1, - LEFT = 0, - RIGHT = 0, - TOP = 1) $ DEFINE/SYSTEM/EXEC TCPIP$TELNETSYM_RAW_TCP "TRUE" $ INITIALIZE /QUEUE - /START - /FORM=PSC - /DEFAULT=FORM=PSC - /NO_INITIAL_FF - /SEPARATE=(NOBURST,NOFLAG,NOTRAILER) - /PROTECTION=( - SYSTEM : E, - OWNER : E, - GROUP : E, - WORLD : E) - /ON="10.1.1.15:9100" - /PROC=TCPIP$TELNETSYM HP_TEXT Set up a queue for printing PCL. For instance: $ INITIALIZE /QUEUE - /START - /NO_INITIAL_FF - /SEPARATE=(NOBURST,NOFLAG,NOTRAILER) - /PROTECTION=( - SYSTEM : E, - OWNER : E, - GROUP : E, - WORLD : E) - /ON="10.1.1.15:9100" - /PROC=TCPIP$TELNETSYM HP_PCL You will need to modify the above /ON qualifiers to match your printer's IP address and port number. ============================================================================== Step 7: Use the following command file _as_a_template_ for more or less comfortable access to the above. ---8<------------------------------------------------------------------------- $! $! File: PSC_PRINT.COM $! Purpose: Pre-processor and print command generator for printing $! ASCII-text and Postscript on HP PCL3 printers. $! Tested: On VAX and Alpha under OpenVMS 7.3 and 7.3-1 with HP PSC2510 $! via 10bT and WLAN. Expected to work with similar printer models. $! Author: Michael Monscheuer, Monscheuer [at] hdw.de $! Date: 17-DEC-2004 $! Version: 2.0 $! $! Usage: Command line: PSC $! XV Print Command: PSC " $! $! Note: The double quote on the last line is NO typo. $! $! Interleaf: Print from DTP application, detour PS output $! to this procedure. $!----------------------------------------------------------------------------- $! $! Check for presence of Ghostscript first $! $ IF F$TRNLNM("GS_LIB") .EQS. "" $ THEN $ WRITE SYS$OUTPUT "GHOSTSCRIPT environment not defined." $ WRITE SYS$OUTPUT "Set up Ghostscript first. Exiting..." $ WRITE SYS$OUTPUT "" $ ENDIF $! $! Initialize symbols $! $ COPIES = "" !Number of copies to print $ PRINT_TYPE = 0 !See below for currently implemented input $ PRINT_FILE = "" !File to be passed to PCL printer $ TEMP_FILE = "" !For temporary internal use only $ PRINT_CMD = "" !Qualifiers to be appended to print command $ PRINT_QUE = "" !Queue to be used with print command $ PS_SETUP = "" !Postscript file for setting up page via Ghostscript $ GHOST_CMD = "" !Ghostscript command to convert PS to PCL $! $! Check for number of requested copies $! $ IF F$INTEGER(P1) .GT. 1 $ THEN $ COPIES = P1 $ P1 = P2 $ ENDIF $! $! Remove unwanted qualifiers provided through default commands of $! either XV or Interleaf $! $ P1 = P1 - " /Delete " $! $! Determine what to print. Currently implemented input: $! $! 0 = plain text $! 1 = Generic Postscript $! 2 = Postscript produced by XV $! 3 = Postscript produced by Interleaf $! $ OPEN/READ 0 'P1' $ READ 0 LINE $ CLOSE 0 $ LL = F$LENGTH(LINE) $ IF F$LOCATE("%!",LINE) .NE. LL .AND. F$LOCATE("PS",LINE) .NE. LL $ THEN $ IF F$LOCATE("%!",LINE) .EQ. 0 $ THEN $ PRINT_TYPE = 1 $ SEARCH/EXACT/NOOUT/NOWARN 'P1' "%%Creator: XV" $ IF $SEVERITY .EQ. 1 THEN PRINT_TYPE = 2 $ SEARCH/EXACT/NOOUT/NOWARN 'P1' "%%Creator: (Interleaf, Inc.)" $ IF $SEVERITY .EQ. 1 THEN PRINT_TYPE = 3 $ ENDIF $ ENDIF $ $ TEMP_FILE = F$PARSE("''P1'",,,"NAME") $ P1 = P1 - F$PARSE("''P1'",,,"VERSION") $! $! Plain ASCII, else basic Postscript setup $! $ IF PRINT_TYPE .EQ. 0 $ THEN $ PRINT_QUE = "HP_TEXT" $! $! The following lines convert DECMCS to M$ CodePage 437 characters, $! say German DOS characters. Change the conversion as you see fit. $! The related ICONV files can be found in SYS$I18N_ICONV. $! $ PRINT_FILE = TEMP_FILE + ".CP437" $ ICONV CONVERT 'P1'/FROM=DECMCS 'TEMP_FILE'.TMP/TO=UCS-2 $ ICONV CONVERT 'TEMP_FILE'.TMP/FROM=UCS-2 'PRINT_FILE'/TO=CP437 $ DELETE/NOCONFIRM 'TEMP_FILE'.TMP;* $ GOTO PRINT_IT $ ELSE $ PRINT_QUE = "HP_PCL" $ PRINT_FILE = TEMP_FILE + ".PCL" $ ENDIF $! $! Generic (1) or XV (2) Postscript $! $! IF PRINT_TYPE .EQ. 1 .OR. PRINT_TYPE .EQ. 2 $! THEN $! Nothing particular to do $! ENDIF $! $! Interleaf Postscript $! $ IF PRINT_TYPE .EQ. 3 $ THEN $ PS_SETUP = "GS_LIB:PRE_ILEAF.PS" $ IF F$SEARCH("GS_LIB:PRE_ILEAF.PS") .EQS. "" $ THEN $ OPEN/WRITE 100 GS_LIB:PRE_ILEAF.PS $ WRITE 100 "%!PS" $ WRITE 100 "% Module to scale output on each page" $ WRITE 100 "% May be used as a queue or device setup module with DCPS on OpenVMS or" $ WRITE 100 "% as a prepended file for processing with Ghostscript" $ WRITE 100 "% Paul Kohler Hewlett-Packard Switzerland / Michael Monscheuer, NMS, Germany" $ WRITE 100 "" $ WRITE 100 "/ScaleDown {" $ WRITE 100 "1 1 scale % x y scale factor, modify as you see fit" $ WRITE 100 "0 8 translate % x y position of image, modify as you see fit" $ WRITE 100 " } bind def" $ WRITE 100 "/old-showpage /showpage load ScaleDown def" $ WRITE 100 "/showpage { old-showpage ScaleDown } bind def" $ WRITE 100 "" $ CLOSE 100 $ ENDIF $ ENDIF $! $! Run Ghostscript to convert Postscript to PCL, cleanup when done. $! $ GHOST "-dNOPAUSE" - "-dBATCH" - "-sPAPERSIZE=a4" - "-sDEVICE=chp2200" - "-dShingling=2" - "-dDepletion=1" - "-r600" - "-dBitsPerPixel=24" - "-sOutputFile=''PRINT_FILE'" - 'PS_SETUP' - 'P1' $! $ DELETE/NOCONFIRM _TEMP*.*;*,'P1';* $! $ PRINT_IT: $! $! Add /COPIES and /PASSALL qualifiers if needed, then PRINT $! $ IF COPIES .NES. "" THEN COPIES = "/COPIES=''COPIES'" $ IF PRINT_QUE .EQS. "HP_PCL" THEN COPIES = COPIES + "/PASSALL" $ PRINT_CMD = "/QUEUE=''PRINT_QUE'/DELETE''COPIES' ''PRINT_FILE'" $ PRINT 'PRINT_CMD' $ ---8<------------------------------------------------------------------------- Define a symbol pointing at this procedure: $ PSC :== @disk:[dir.sub]PSC_PRINT.COM Do not forget to add the latter to either your personal or a system wide login procedure. Hints: You now even can use XV (image viewer and manipulator) to print images DIRECTLY to the PCL3 printer. When tapping XV's "print" button, remove the command line in the pop-up window and simply replace it with the string PSC <# of copies>" (double quote is NO typo). XV's PS output will first go to GS which then will send its PCL output to the printer automatically. Equivalent setups should be possible with ImageMagick and similar SW. In case you are running the Interleaf DTP software, you also can use the above procedure to print Interleaf documents on your HP PCL printer. Setup a new LN03 printer inside Interleaf and don't let the files being spooled to the new printer. Printing Interleaf documents to the new printer then results in a Postscript file in your IWS#DESKTOP subdirectories. Pass this PS-file to the above procedure. The latter can be automated by a detached process scanning your IWS#DESKTOP directories for PS files. ============================================================================== Finally test your setup by printing a PS file on your PCL3 printer: $ PSC <# of copies> MYFILE.PS