Outputting Text
Living Linux

Outputting Text

04/04/2000

As we discussed last week, the next few columns in this series will describe some of the available tools and applications for doing word processor-like things with Linux.

GNU Enscript is a tool that takes plain text as input and writes PostScript output, doing any number of formatting changes in between. It's great for quickly making nice output of a plain text file -- you can use it to do things like output text in a font of your choosing, or paginate text with graphical headers at the top of each page.

By default, enscript paginates its input, outputs it in a 10-point Courier font, and puts a simple header at the top of each page containing the filename, date and time, and page number in bold. Use the -B option to omit this header.

If you have a PostScript printer connected to your system as the default printer, enscript spools its output right to the printer. You can verify this on your system by looking at the enscript configuration file, /etc/enscript.cfg. The line DefaultOutputMethod: printer specifies that output is spooled directly to the printer; stdout instead of printer sends to the standard output instead.

Most Linux installations nowadays have print filters set up so that PostScript spooled for printing is automatically converted to a format the printer understands (if your system doesn't have this set up for some reason, convert the PostScript to a format recognized by your printer with the gs tool).

For example, to convert the file report.txt to PostScript with default formatting, and spool the output right to the printer, you'd type:

$ enscript report.txt RET

You can write the output to a file instead with the -p option, which takes the name of the file to output as an argument. This is useful for previewing the output before you print it -- view it on the screen with a PostScript viewer application like ghostview.

To write the file report.txt to a PostScript file report.ps, and then preview it, you'd type:

$ enscript -p report.ps report.txt RET

$ ghostview report.ps RET

Printing text in a font

To output text in a particular font, give the name of the font to use as a quoted argument to the -f option.

Specify both the font family and size in points: give the capitalized name of the font family (with hyphens to indicate spaces between words) followed by the the size in points. For example, Courier14 outputs text in the Courier font at 14 points, and Times-Roman12.2 outputs text in the Times Roman font at 12.2 points. A list of available font names are in the file /usr/share/enscript/afm/font.map; the enscript man page describes how to use additional fonts that might be installed on your system.

To print the contents of the text file report.txt in the Helvetica font at 12 points, type:

$ enscript -B -f "Helvetica12" report.txt RET

When headers are used, they're normally output in 10-point Courier Bold; to specify a different font for the text in the header, give its name as an argument to the -F option.

To print the contents of the text file report.txt with text set in 10-point Times Roman and header text set in 18-point Times Bold, type:

$ enscript -f "Times-Roman10" -F "Times-Bold18" report.txt RET

 

[1] [2] [3] Next

Close    To Top
  • Prev Article-OS:
  • Next Article-OS:
  • Now: Tutorial for Web and Software Design > OS > Linux > OS Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction