Are you looking for an easy way of extracting text from PDF files? If yes, you have landed to the right place as in this article, you will learn how to convert a PDF file to plain text in Python.

Convert PDF to Text in Python

PDF is a well-known and globally used document format because of its cross platform support. Many people prefer to share and print the documents in PDF format. Since PDF is very much in the business, you may need to extract plain text from multiple PDF files programmatically for text analysis or further processing. So let’s see how to perform PDF to text conversion from within a Python application.

Python PDF to Text Converter Library - Free Download

Aspose.Words for Python is a powerful library that is designed to manipulate popular text document formats, which mainly include MS Word and PDF files. Using the library, you can easily process the text in the documents. We will use this library to convert the PDF files to plain text (TXT).

You can use the following pip command to install Aspose.Words for Python in your application.

pip install aspose-words

How to Convert PDF to Text in Python

To convert a PDF file to plain text using Aspose.Words for Python, we will perform the following steps:

  • Load the PDF document from disk.
  • Save PDF as TXT format to desired location.

And that’s it.

Now, let’s see how to perform these steps in Python to convert a PDF file to TXT format.

Save PDF as TXT File in Python

The following are the steps to save a PDF file as TXT in Python.

  • Load the PDF file using Document class.
  • Save PDF as TXT using method and pass the file’s path as parameter.

The following code sample shows how to convert a PDF file to text (TXT) in Python.

Python PDF to TXT Converter - Get a Free License

You can use a free temporary license to save PDFs as TXT files without evaluation limitations.


In this article, you have learned how to convert PDF files to text in Python. With the help of code sample, you have seen how to load and save PDF as TXT file to desired location in Python. Besides, you can visit the documentation of Aspose.Words for Python to explore more about the library. In case you would have any questions, feel free to let us know via our forum.

See Also