Menu

1 / 2

Pay Stub OCR: Extract Income, Deductions, and Employer Details With Python

DEV Community: python·Unsiloed AI·7 days ago
#LsvvC0Pv
#devtopython#devto#dev#stub#gross
Reading 0:00
15s threshold

By Aman Mishra. Originally published on Unsiloed AI .

A pay stub prints its own arithmetic. The earnings lines add up to gross pay, gross pay minus taxes and deductions is net pay, and a year-to-date total is normally at least the same total for this period. That gives you a way to check pay stub OCR output against the stub itself.

In this guide, we use Python and the Unsiloed API to extract a pay stub to JSON, with the employer, the pay period, every earnings line, and every tax and deduction. The extraction API returns a confidence score on each value and a box marking where it sits on the page. Then we use Python to check the figures against each other and turn a stub that passes into an income record with annualized gross pay.

The examples are two public sample pay stubs. The first is the sample paycheck stub the University of South Carolina publishes for its employees, a salaried PeopleSoft stub that's embedded in the PDF as a low-resolution image.…

Continue reading — create a free account

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