ARCHIVED: In Unix, how do I convert a PostScript file to text?

A PostScript file is a text file that describes how to place text and graphics on paper. While there are many programs available for generating PostScript files from text, converting a PostScript file back to normal text is more difficult. Extracting the raw text and graphics that originally composed the document from the special instructions in the PostScript file is not a straightforward task.

Ideally, you should try to obtain a copy of the original text from the creator of the PostScript file. If you're unable to do so, you can try using the script below, which invokes Ghostscript, the PostScript and PDF interpreter and previewer:

  1. Copy the following text and save it to a file; make sure long lines are saved as single lines:
     #!/bin/sh if ( test $# -eq 0 ) then gs -q -dNODISPLAY -dNOBIND -dWRITESYSTEMDICT -dSIMPLE ps2ascii.ps - -c quit elif ( test $# -eq 1 ) then gs -q -dNODISPLAY -dNOBIND -dWRITESYSTEMDICT -dSIMPLE ps2ascii.ps $1 -c quit else gs -q -dNODISPLAY -dNOBIND -dWRITESYSTEMDICT -dSIMPLE ps2ascii.ps $1 -c quit >$2 fi
  2. Add execute permission to the file. For example, if you saved the script as ps2ascii, at the command prompt, enter:
     chmod u+x ps2ascii
  3. Run the script on your PostScript file. For example, if the PostScript file is named myfile.ps, and you want the output saved to myfile.txt, at the command prompt, enter:
     ./ps2ascii myfile.ps > myfile.txt

Note: The results will likely not be perfect, because of the difficulty involved in extracting the text, so some editing of the output file may be necessary to make it presentable.

At Indiana University, Ghostscript is installed on Big Red II, Karst, and Mason. To invoke it from the command line, use the gs command. For more about Ghostscript, see the gs manual page.

Support for IU research computing systems, software, and services is provided by various UITS Research Technologies units. For help, see Research computing support at IU.

This is document abcd in the Knowledge Base.
Last modified on 2018-01-02 09:09:18.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.