Menu

1 / 3

How to Extract Data From a PDF Form With Python (and Into Excel)

DEV Community: python·Unsiloed AI·7 days ago
#4Mt7F3Cw
#devtopython#devto#dev#form#fields
Reading 0:00
15s threshold

By Aman Mishra. Originally published on Unsiloed AI .

This guide uses Python to extract data from a PDF form into JSON, check the amounts, and export them to Excel. If the PDF is fillable, we can read its stored fields directly with pypdf. A flattened PDF or a scan has no stored fields, so the values have to be read from the page itself.

The example throughout is an IRS Form W-2. A W-2 is the yearly statement a US employer gives each employee. It shows what the employee earned and how much tax the employer withheld from their pay. We use the same W-2 in three versions: a fillable form, a flattened PDF, and a scan.

How PDF Forms Store Data

A PDF can look like a form without containing interactive fields.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.