1 PSTOTEXT PSTOTEXT - extract ASCII text from a PostScript or PDF file Syntax: pstotext [option|pathname]... where option includes: -cork -landscape -landscapeother -portrait - -gs command -debug -bboxes -output file 2 Description PSTOTEXT reads one or more PostScript or PDF files, and writes to standard output a representation of the plain text that would be displayed if the PostScript file were printed. As is described in the DETAILS section, this representation is only an approximation. Nevertheless, it is often useful for information retrieval (e.g., running grep(1) or building a full-text index) or to recover the text from a PostScript file whose source you have lost. PSTOTEXT calls Ghostscript, and requires Aladdin Ghostscript version 3.51 or newer. Ghostscript must be invokable on the current search path as gs. Alternatively, you can use the "-gs" option to specify the command (pathname and options) to run Ghostscript. PSTOTEXT reads and processes its command line from left to right, ignoring the case of options. When it encounters a pathname, it opens the file and expects to find a PostScript job or PDF document to process. The option "-" means to read and process a PostScript job from standard input. If no - or pathname arguments are encountered, PSTOTEXT reads a PostScript job from standard input. (PDF documents require random access, hence cannot be read from standard input.) The option -cork is only relevant for PostScript files produced by dvips from TeX or LaTeX documents; it tells PSTOTEXT to use the Cork encoding (known as T1 in LaTeX) rather than the old TeX text encoding (known as OT1 in LaTeX). Unfortunately files produced by dvips don't distinguish which font encodings were used. The options -landscape and -landscapeother should be used for documents that must be rotated 90 degrees clockwise or counterclockwise, respectively, in order to be readable. The options -debug and -bboxes are mostly of use for the maintainers of PSTOTEXT. -debug shows Ghostscript output and error messages. -bboxes outputs one word per line with bounding box information. 2 Details PSTOTEXT does its work by telling Ghostscript to load a PostScript library that causes it to write to its standard output information about each string rendered by a PostScript job or PDF document. This information includes the characters of the string, and enough additional information to approximate the string's bounding rectangle. PSTOTEXT post-processes this information and outputs a sequence of words delimited by space, newline, and formfeed. PSTOTEXT outputs words in the same sequence as they are rendered by the document. This usually, but not always, follows the order that a human would read the words on a page. Within this sequence, words are separated by either space or newline depending on whether or not they fall on the same line. Each page is terminated with a formfeed. If you use the incorrect option from the set {-portrait, -landscape, -landscapeother}, PSTOTEXT is likely to substitute newline for space. A PostScript job or PDF document often renders one word as several strings in order to get correct spacing between particular pairs of characters. PSTOTEXT does its best to assemble these strings back into words, using a simple heuristic: strings separated by a distance of less than 0.3 times the minimum of the average character widths in the two strings are considered to be part of the same word. Note that this typically causes leading and trailing punctuation characters to be included with a word. The PostScript language provides a flexible encoding scheme by which character codes in strings select specific characters (symbols), so a PostScript job is free to use any character code. On the other hand, PSTOTEXT always translates to the ISO 8859-1 (Latin-1) character code, which is an extension to ASCII covering most of the Western European languages. When a character isn't present in ISO 8859-1, PSTOTEXT uses a sequence of characters, e.g., "---" for em dash or "A\\226" for Abreve. PSTOTEXT can be fooled by a font whose Encoding vector doesn't follow Adobe's conventions, but it contains heuristics allowing it to handle a wide variety of misbehaving fonts. (PSTOTEXT no longer translates hyphen (\\255) to minus (\\055).) 2 Options -cork assume Cork encoding for dvips output -landscape rotate 270 degrees -landscapeother rotate 90 degrees -portrait don't rotate (default) -bboxes output one word per line with bounding box -debug show Ghostscript output and error messages -gs "command" Ghostscript command -output file output results to "file" (default is stdout) - read from stdin (default if no files specified) 2 Authors Andrew Birrell (PostScript libraries), Paul McJones (application), and Russell Lang (Windows and OS/2 adaptation). VMS port by Hunter Goatley. 2 See_Also PSTOTEXT incorporates technology originally developed for the Virtual Paper project at SRC; see http://www.research.digital.com/SRC/virtualpaper/ As mentioned above, PSTOTEXT invokes Ghostscript. See gs(1) or http://www.cs.wisc.edu/~ghost/. 2 Copyright Copyright 1995 Digital Equipment Corporation. Distributed only by permission. See file pstotext.txt for details.