How to Extract Text from PDF and Paste in Excel using Python and PDF.co Web API

Sep 2, 2024·3 Minutes Read

Here’s one more guide about invoice data extraction. In this tutorial, we will convert a PDF to Excel in Python using the PDF.co API.

Step 1: Download Files

Download the Python source code for this Tutorial from our Github.

Step 2: Install Requests Module

Next, let’s install the requests module in Python. Kindly open your command line (cmd.exe) and enter this command:

python -m pip install requests

Step 3: Add API Key

Then, let’s open the Python code in Visual Studio Code or in your preferred editor. Add your API Key on line 6. You can get it in your PDF.co Dashboard.

Step 4: Add PDF Invoice

On line 12, type in the source sample PDF Invoice. You can add your desired output filename in line 18 or leave the default value.

Step 5: Run Program

Now let’s run the program from the command line with:

python ConvertPdfToExcelFromUploadedFile.py

and check the folder to see the output. You should see a resulting XLS file appear. You have successfully extracted the text from the PDF to an XLS format.

In this tutorial, you learned how to extract PDF contents and paste them into Excel using Python. You learned to use the PDF.co PDF Extractor Web API to easily convert a PDF to Excel. You also learned how to get started with PDF Extractor Web API right away using the Python sample code.

Related Tutorials

See Related Tutorials