Knowledge Base

How do I print to PDF in SCO Unix OpenServer or UnixWare

  1. Create a directory to store the PDF files:

    mkdir /usr/pdf

    chown lp:lp /usr/pdf
  2. Create an HPNP style PostScript printer with /usr/lib/hpnp/hpnpcfg

    choose option 6 – Add a printer

    printer name: pdfptr

    peripheral name <ENTER>
    (ignore error about unknown peripheral)

    (For UnixWare, hit return for all additional options)
    model script: postscript

    spooler class: <ENTER>

    choose q to quit
  3. Replace the HPHPF script with script to convert to pdf.

    vi /usr/spool/lp/admins/lp/interfaces/pdfptr

    Erase all contents of the file and replace with:


    MODEL=basename $0
    REALMODEL=echo $0 | sed -e "s%$MODEL%model.orig/$MODEL%"
    $REALMODEL “$@” | ps2pdf – “/usr/pdf/${1}.pdf”
  4. For UnixWare systems only (OpenServer systems skip this step):

    lpadmin -p pdfptr -I postscript -T PS-b

    cp /etc/lp/model/PS /etc/lp/interfaces/model.orig/pdfptr
  5. Restart scheduler:


To create a PDF:

lp -d pdfptr

For Example:

lp -d pdfptr /etc/hosts

request id is pdfptr-32

The PDF file will be in the /usr/pdf/ directory:


NOTE: To modify the pdfptr to handle wide reports:

vi /usr/spool/lp/admins/lp/interfaces/model.orig/pdfptr

find the line:


change this to:


Create a file called text2post16

cp /usr/spool/lp/bin/text2post /usr/spool/lp/bin/text2post_16

vi /usr/spool/lp/bin/text2post_16

This filter converts the text file to postscript and sets values that control the margins, size of the font and size of page.

These can be changed to handle a wider document. In the file /usr/spool/lp/bin/text2post_16, find the function port_head(), Inside this function, find:

  /margin 36.0000 def

change this to:

  /margin 16.0000 def

To change the size of the characters

find the line:

/$FONT findfont 9 scalefont setfont

change this to:

/$FONT findfont 5 scalefont setfont

To make the page accept more lines per page in the port_proc() function,


(line>65) { line=0; print “Page” }

change this to:

(line>85) { line=0; print “Page” }

The text2post_16 script also looks for ^L type form feeds, but it wants them to be at the beginning of the line. If you have form feeds which are not at the beginning of the line, you could use a pre-filter, to change the position of the ^L character. For this you could use a script similar to


cat $input|while read line
case $line in
^L) pt1=echo $line|awk -F^L '{print $1}'
pt2=echo $line|awk -F^L '{print $2}'
echo “$pt1”
echo “^L”
echo “$pt2”;;
*) echo “$line”;;

The ^L characters need to be and not ^ L, so cut & paste of this script will not work properly without edits. IFS is being set to a carriage return only, don’t include any spaces. For your convenience a copy of this is also available at:

To use this filter, you would use the syntax:

cat reportfile | | lp -d pdfptr

NOTE: OpenServer 5 customers who have removed CUPS will need the CUPS libraries for the ps2pdf ghostscript utility. These are available separately at:

NOTE: This script can be modified further to email the PDF files to the user that submitted the script. Using MUTT for the mailer is better for mailing attachments. MUTT can be installed from
Skunkware using patchck:

/etc/patchck mutt

With MUTT installed, you could append these lines to the end of

mutt -s “$1 PDF report” -a “/var/pdf/${1}.pdf” $USER < /dev/null

This will mail the PDF file as a mime encoded attachment to the user that submitted the print job. If the user has an external email address, you could setup a ~/.forward file for that user with the user’s external email address to have the file sent externally.

1995 reads
How did you like this article?0000