The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации / Документация по FreeBSD / Руководства по FreeBSD на английском

8.12 Advanced Printing Topics

The FreeBSD UNIX LPR/LPD printing system is very flexible, and, with the addition of filters, can be adapted to very unusual printing environments. To enhance this flexibility, several useful printing utilities are supplied on the FreeBSD CDROM which the administrator might wish to install.

8.12.1 Ghostscript

The Ghostscript program, invoked as /usr/local/bin/gs, is one of the most useful printing utilities that have been developed for the free software community. Ghostscript reads incoming PostScript data, (or Adobe PDF files) interprets it, and outputs it as a raster image. This can be displayed on screen, for example, with the GhostView program under the X Window system, or printed on most graphics printers, such as Epson dot-matrix, HP DeskJet, or HP LaserJet. In effect, it is a way of adding PostScript printing capability to a printer that doesn't have PostScript firmware code. Ghostscript has been ported to numerous operating systems including Windows.

The Ghostscript home page is located at and contains the most current version of the program. A prebuilt FreeBSD binary of Ghostscript is located in the Packages section of the FreeBSD CDROM. This can be installed on the FreeBSD system by selecting the package from the prepackaged software list that is accessed through the /stand/sysinstall installation program. Many packaged programs on the CD depend on GhostScript, and so it may already be installed.

Installation of the packaged version of GhostScript is recommended in the FreeBSD ports Section because it has been tested with the other packages that require it. The package creates a directory containing some documentation files in /usr/local/share/ghostscript/X.XX/doc. Unfortunately, because of the packaging process on the FreeBSD CDROM not all the useful installation files are copied into this location. So, if the package was version 5.03 (for example) the administrator will also want to get the file, and unzip and untar it into a temporary directory.

Extracting the archive file creates a directory structure under the gs5.03 subdirectory. To install ghostscript in the /etc/printcap file, read the gs5.03/devs.mak file to determine which printer driver definition works with your printer and then use the following instructions:

  1. Change to the root user with su.

  2. In the gs5.03 directory, copy the, unix-lpr.txt, and files to /usr/local/share/ghostscript/5.03.

  3. Change to the /usr/local/share/ghostscript/5.03 directory. Edit with a text editor such as vi.

  4. Modify the DEVICES= entries to list your selected printer driver definitions per the instructions in unix-lpr.txt.

  5. Modify the PRINTERDEV= to /dev/lpt0, and the GSDIR= to /usr/local/share/ghostscript, and the SPOOLDIR= to /var/spool/output. Save the file.

  6. Edit the file and change the PSFILTERPATH= to /usr/local/share/ghostscript.

  7. If the printer that you defined in the file is a monochrome printer, remove the "-dBitsPerPixel=${bpp}" and "$colorspec" entries on the gs invocation line and save the file. Otherwise, if it is a color definition leave them in. For example, the following line is for a monochrome LaserJet:

        ") | gs -q -dNOPAUSE -sDEVICE=${device} \"

    Don't remove anything else. Exit the editor, and save the file.

  8. Copy the file to the parent directory, /usr/local/share/ghostscript and set the execute bit on it.

  9. Set the execute bit on with chmod and run the file by typing ./

  10. Follow the instructions on creating the Spool directories. If you will be using accounting and a separate log file, run the touch command to create the empty files per directions in script output.

  11. The sample /etc/printcap is located in the current directory; the filename is printcap.insert. Use this as a template to modify the /etc/printcap file. A sample /etc/printcap file for a LaserJet 3 is below:

        ljet3.raw|Raw output device ljet3 for Ghostscript:\
        ljet3|Ghostscript device ljet3 (output to ljet3.raw):\

8.12.2 a2ps filter

Another handy utility is the a2ps filter, short for ASCII-to-PostScript. This program takes an incoming ASCII datastream and converts it into PostScript. It can also print multiple pages on a single sheet of paper by shrinking them down. It is a useful tool for a printer that cannot interpret ASCII, such as a PostScript-only printer.

A2ps is not installed in the FreeBSD system by default; it is located in the ports section /usr/ports/print/a2ps43. A prepackaged binary can be installed with /stand/sysinstall but I have had problems with that port. It is best to install it by running make in the a2ps43 ports directory. A printcap entry and filter using this follow:

Example 8-3. /etc/printcap

    lp|local line printer with output dumped through a2ps for raw listings:\

Example 8-4. /usr/local/libexec/ascii2postscript

    # Simple filter that converts ASCII to PostScript for basic stuff like
    # directory listings.
    /usr/local/bin/a2ps && exit 0
    exit 2

Read the system manual page for a2ps to see the options available with this program, and remember to set the filter script ascii2postscript all-executable.

This, and other documents, can be downloaded from

For questions about FreeBSD, read the documentation before contacting <>.
For questions about this documentation, e-mail <>.

Inferno Solutions
Hosting by

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру