Is there an easy way to extract plain text from a pdf file?

On *nix systems I used to have a command ps2ascii that would do the job, but it seems that this command is not installed by default on my Mac.

What would be the easiest way to extract text from a pdf file or, alternatively, how to get ps2ascii on my system?


Adobe Reader has a "Save as Text…" option under the File menu. Easiest way.

  • Thanks! This is by far the most simple solution, it was able to cope with my huge file without any problems and produced a reasonably clean and usable text output. – Juan A. Navarro Sep 27 '10 at 11:14
  • 1
    Yes, it is the easiest, but not always the cleanest output. v7 output the best, but things go haywire before and after that. Part of my job is to supply plain text versions of college textbooks to disabled college students. I have a lot of experience with this, and that's why I recommend Ghostscript if looking for the free option. – Philip Regan Sep 27 '10 at 13:43
  • 1
    @ghoppe thanks to this easy option but it is not available in mac version of adobe,how to make it in adobe via Adobe reader? – user11707 Oct 7 '11 at 5:35

ps2ascii is a part of Ghostscript, which can be installed on Mac OS X (and it might already be by default from the factory).

  • 1
    Ghostscript is not included with OSX. Tho any of the methods listed below would happily install it. – Martin Marconcini Sep 22 '10 at 14:02
  • I don't know if I'm pushing it too much but could you give me details on exactly what do I have to install and how? (Full disclaimer: I'm a fairly experienced user and I've already managed to install it, but on the beta stage of this site I would like to see how much detail and information are we to expect from people giving answers.) – Juan A. Navarro Sep 23 '10 at 16:17
  • I think a question like that would step out of the scope of SE since there are already very detailed docs available on their site. A more suitable question in this case, as far as I see it, would be to post a question related to installation after you've tried to install it, installation fails after repeated attempts, and searching the web yields little or no answers. – Philip Regan Sep 23 '10 at 16:49

I’m not aware of any OS X native utility that does that, however, you can install most of the unix/linux commands with any of these three methods:

Homebew: Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn't include with OS X.

Fink: The Fink project wants to bring the full world of Unix Open Source software to Darwin and Mac OS X.

Macports: The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system.

Homebrew is the “new kid on the block” and promises to solve the “problems and limitations” that the other two have (whatever those problems may be). I suggest you take a look at all of them and use what you consider most flexible/simple for your needs.

There is, however, an app (Payware) that used to do that (I don’t know if it still does it). I’m talking about DEVONthink, and you can try a demo for a few days.

update: According to this post, you could install DevonThink (trial version) and extract the ‘pdftotext’ binary "which is free, of course" [sic] out of the bundle.

  • Thanks for the pointers, but which of these would actually contain ps2ascii? And which one should I prefer? – Juan A. Navarro Sep 23 '10 at 16:10
  • MacPorts handles Ghostscript 9 (the latest version). – Philip Regan Sep 23 '10 at 16:51
  • OS X native utility is the Adobe Reader application, which has Save as Text. – ghoppe Sep 23 '10 at 20:21

If you don't mind using a GUI, you can select text from a PDF opened with Preview.app

  • Thanks, this seems to work for simple cases. But I've got a very large document (over 1000 pages) and it almost crashes the system just by trying to select-all! – Juan A. Navarro Sep 23 '10 at 16:09
  • An offbeat solution related to the above answer is that Acrobat 7 actually made surprisingly clean text extractions (but you are better off using a proper utility like ghostscript for something that large). – Philip Regan Sep 23 '10 at 16:53

Use Online document converters like Saaspose.PDF that can convert your PDF file to a TXT-based document. And because its a cloud API, there is no need to download or install anything.


The following python script will output the text from a PDF document to a .txt file. (Note: There is no guarantee that the text is necessarily in 'logical' human readable order, due to the way that data is held in the PDF format.)

The script will create text files for any PDF files supplied as arguments to it on the command line (e.g. pdf2txt.py myPDF.pdf), or you can use in Automator's "Run Shell Script" action, setting the shell type to python and Pass input to "As arguments".

# coding: utf-8

import os, sys
from Quartz import PDFDocument
from CoreFoundation import (NSURL, NSString)
NSUTF8StringEncoding = 4

def pdf2txt():
    for filename in sys.argv[1:]:   
        inputfile =filename.decode('utf-8')
        shortName = os.path.splitext(filename)[0]
        outputfile = shortName+" text.txt"
        pdfURL = NSURL.fileURLWithPath_(inputfile)
        pdfDoc = PDFDocument.alloc().initWithURL_(pdfURL)
        if pdfDoc :
            pdfString = NSString.stringWithString_(pdfDoc.string())
            pdfString.writeToFile_atomically_encoding_error_(outputfile, True, NSUTF8StringEncoding, None)

if __name__ == "__main__":

You must log in to answer this question.

Not the answer you're looking for?Browse other questions tagged .