ps2ascii
Convert PostScript files to plain text
SYNOPSIS
ps2ascii [input_file.ps [output_file.txt]]
PARAMETERS
input_file.ps
The path to the PostScript file to be converted. If omitted, ps2ascii reads from standard input (stdin).
output_file.txt
The path to the file where the ASCII text output will be written. If omitted, ps2ascii writes to standard output (stdout).
DESCRIPTION
ps2ascii is a utility that takes a PostScript file as input and attempts to extract human-readable text from it, outputting plain ASCII text. It is often used for quick previews or to get textual content from PostScript documents without needing a full PostScript viewer or printer. It works by interpreting PostScript drawing commands and trying to identify characters and their positions. The output is typically not a perfect reproduction of the original layout but provides the sequential text content.
It is built upon Ghostscript (gs) and leverages its PostScript interpreter capabilities. This command is particularly useful for scripting, indexing PostScript documents, or when you need to process text from PostScript without a graphical interface. It is a simple text extraction tool, not a layout conversion tool, meaning graphical elements and complex formatting are ignored.
CAVEATS
Layout, images, and non-textual elements from the original PostScript document are ignored. Complex PostScript files or those with unusual font encodings may result in incomplete or garbled text output. It relies heavily on the underlying Ghostscript installation; its limitations are Ghostscript's limitations.
UNDERLYING TECHNOLOGY
ps2ascii is fundamentally a wrapper script for Ghostscript (gs). It invokes gs with specific options like -sDEVICE=ps2ascii, -dBATCH, and -dNOPAUSE to perform the text extraction. This means its functionality and limitations are directly inherited from the Ghostscript ps2ascii device driver. Any options passed to ps2ascii on the command line, beyond the input/output filenames, are usually passed directly to the underlying gs command, though ps2ascii itself doesn't define standard options for its own behavior.
HISTORY
ps2ascii typically exists as a simple shell script wrapper provided with Ghostscript distributions. Its development is not an independent project but rather an abstraction built upon Ghostscript's internal ps2ascii device driver. It has been a standard utility in Unix-like environments for basic text extraction from PostScript since the early days of PostScript processing.