enscript
Convert text files for printing
TLDR
Generate a PostScript file from a text file
Generate a file in a different language than PostScript
Generate a PostScript file with a landscape layout, splitting the page into columns (maximum 9)
Display available syntax highlighting languages and file formats
Generate a PostScript file with syntax highlighting and color for a specified language
SYNOPSIS
enscript [options] [file ...]
PARAMETERS
-B
Do not output a header page.
-c
Print
-C
Output C-style code highlighting (if supported by the output mode).
-d
Send the output to the default printer.
-D
Sets the default font used for most text.
-f
Selects the font to be used in the output.
-F
Selects the font for the header.
-h
Sets the header text.
-H
Output HTML format.
-j
Passes job name to spooler. If job name is not given, uses the first input file's name as job name.
-m
Sets page margins (left:right:top:bottom).
-M
Selects the output media (e.g., a4, letter).
-n
Sets the number of logical pages on each physical sheet.
-o
Specifies the output file; if not given, output goes to standard output.
-p
Sends the output to the specified printer.
-r
Rotates the output 90 degrees (landscape).
-s
Sets the font size.
-t
Sets the title of the output.
-v
Verbose mode.
--color[=
Enables/disables color syntax highlighting (default: auto).
DESCRIPTION
enscript is a powerful command-line tool for converting plain text files to PostScript, HTML, or other formats for printing or display. It allows users to format text with specific fonts, margins, headers, footers, and other stylistic elements.
enscript is especially useful for creating professional-looking printouts of source code, documentation, or any other text-based content. It offers extensive customization options to tailor the output to specific needs. It is often used in scripting to automate document creation or format data for printing. enscript supports different languages and can highlight code syntax. It is an old but still viable solution when printing or converting text is a need, for example when printing to old line printers.
CAVEATS
enscript relies on PostScript interpreters and might require appropriate configurations for specific printers. Its output quality can depend on the fonts and settings used.
LOCALIZATION
enscript supports localization, allowing you to use different character encodings and languages. LANG and LC_ALL environment variables affect the output.
SYNTAX HIGHLIGHTING
enscript offers syntax highlighting for various programming languages like C, C++, Python, etc. Use the -C option for C-style highlighting or specify the language with the --language option.
HISTORY
enscript has been available on Unix-like systems for a very long time and was often used to print to line printers and similar. It was developed as a tool to provide formatted output from text files before more advanced word processors and document formatting tools became widely available.