New Tool Radar

AI PDF

How to Extract Line Items from a PDF Invoice and Check Them Against the Invoice Total

Extract the invoice table with Camelot, add up the line amounts, and compare the sum with the printed total to catch a missing or wrong line.

Schematic with three steps: Extract the line-item table; Sum the line amounts; Compare the sum with the printed total.

An invoice total is only trustworthy if its line items add up to it. Extracting the table, summing the amounts, and comparing the sum with the printed total catches a line that was dropped, doubled, or misread.

What you need

  • Python with Camelot installed
  • A PDF invoice with a line-item table
  • A spreadsheet or calculator to sum the amounts
  • A terminal

Step 1: Extract the line-item table

Run Camelot on the invoice page with lattice mode if the table has ruling lines or stream mode if it does not, and export the table to CSV.

Step 2: Sum the line amounts

Open the CSV, read each line amount, and add them together, keeping tax and discounts as separate lines so the arithmetic matches the invoice’s own structure.

Step 3: Compare the sum with the printed total

Read the total printed on the invoice and compare it with your sum. Investigate any difference by re-reading the lines on the page, and do not pay an invoice whose lines do not add up.

Worked example: synthetic invoice check on a 3-line invoice

The table below is a synthetic example. It shows the expected result of the line-item check; no extraction was run.

Line Amount Running total
Hosting, 12 months 120.00 120.00
Domain renewal 15.00 135.00
Support hours 60.00 195.00
Invoice total 195.00 Matches the sum

Expected result (UNTESTED). the three line items sum to 195.00, which matches the printed invoice total, so the invoice is internally consistent. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Camelot can misread a line if the table has merged cells or wrapped text, so check the CSV against the page.
  • Tax, discounts, and currency conversion must be handled exactly as the invoice states them.
  • An invoice total that matches its lines is still not proof the charges themselves are correct.

Sources

See all