How to Split Multi-Invoice PDFs in Airparser Before Parsing
Multi-invoice PDFs break Airparser parsing because one document returns one JSON object. When a vendor emails a single 40-page statement covering 20 invoices, you get one giant object instead of 20 rows. Fix it by splitting pages before upload, or by setting the schema to return an array of invoice objects.
This is the most common complaint about document AI tools, and it is not really a parsing problem. It is a modelling decision you make before the first upload.
How do you tell whether a PDF holds one invoice or many?
Open the file and check three things:
- Repeating invoice numbers. If pages 3, 9 and 14 each show a different “Invoice No.”, it is a batch.
- A summary page. Statements usually end with a total page listing all invoices. Good sign, because you can validate against it.
- Consistent headers. If page 5 has a different supplier logo, someone stitched two PDFs together and the layouts differ.
Count the distinct invoice numbers and compare against the page count. Two invoices per page is normal for compact logistics statements.
Step 1: Choose between page splitting and array output
Two viable routes, with clear tradeoffs.
Page splitting. Use a PDF library (pypdf, pdf-lib) to cut the file, then upload each chunk to Airparser separately. You get one clean document per invoice and every extraction is simple. Cost: one document credit per invoice, and you need to detect the split boundaries reliably.
Array output. Keep the whole PDF as one document, and design the Airparser schema so the invoice fields are a repeating array. One credit for the whole batch. Cost: LLM output token limits. A 40-page statement with 200 line items will exceed the context window and get truncated mid-array.
My rule: split when the file is over 10 pages or holds more than 5 invoices. Keep the array approach for small, predictable batches.
Step 2: Split by detecting invoice headers
Blind “split every three pages” fails on the first supplier who adds an attachment page. Detect boundaries instead.
With pypdf, extract text from each page and look for your invoice-number pattern. The regex depends on the vendor — a hint, not Gospel: many German suppliers use Rechnungsnr. followed by eight digits, US distributors usually print Invoice # plus a six digit sequence.
Build a list of pages where the pattern appears. Each page in that list starts a new invoice; everything after it belongs to that invoice until the next hit. Pages before the first hit (cover letters, terms) get dropped or attached to invoice one.
Test the splitter on 20 real files before letting it loose on the monthly batch, and print the page ranges it chose. Off-by-one errors are easy to spot in a range list and hard to spot in a JSON payload.
Step 3: Tune the schema for the real messiness
Once documents are one-invoice-each, the schema work gets simple. A stable field set for accounts payable:
| Field | Type | Note |
|---|---|---|
| vendor_name | string | often on the letterhead only |
| invoice_number | string | keep exactly as printed |
| invoice_date | date | force ISO, watch DD/MM vs MM/DD |
| due_date | date | may be “Net 30” instead |
| total_amount | number | exclude tax if you track separately |
| currency | enum | default from vendor master |
Date parsing is where you lose money. A 03/04/2026 invoice is March 4 in the US and April 3 in most of Europe. Set the locale per template, and if you cannot, add a review flag for any date where day and month are both under 13.
Step 4: Handle supplier statements differently
A statement is a list of invoices, not an invoice. Two traps:
- It includes a summary that looks like an invoice. The last page repeats every number and adds a grand total. Split your detection so the summary page is excluded.
- Invoice numbers appear multiple times. Once in the list, once in the detail. A naive “one row per number found” produces duplicates.
Deduplicate on invoice number after extraction, keeping the row with the most line items. That single rule removes most duplicate documents.
What does this cost at scale?
Airparser bills per document. At the entry tier around $39/month for roughly 300 documents, a 200-invoice month split into 200 documents uses two-thirds of your allowance. If you are processing 2,000 monthly, the per-document pricing on higher tiers matters more than the parser’s accuracy.
The splitting step is free — it runs locally — but adds operational surface: a queue, a temp directory, cleanup. Budget half a day for that, not fifteen minutes.
Who should do this, and who should pick something else
Fits teams receiving batch statements from distributors, freight forwarders and utilities. Also fine for anyone whose vendor sends 40-page monthly packs as a matter of policy.
Bad fit if you need line-item extraction with high accuracy across scanned, rotated or handwritten invoices. Airparser handles clean digital PDFs well; for camera scans the OCR layer degrades fast and splitting does not help.
One honest limitation: there is no native PDF splitting in the dashboard. Everything above happens in your own script, before upload. Airparser will happily accept a 40-page batch PDF and return one confusing blob, and nothing warns you it did.
Quick Summary
- One Airparser document returns one JSON object, so batch PDFs need splitting or array schemas.
- Split when a file is over 10 pages or contains more than 5 invoices; use array output below that.
- Detect invoice boundaries by header pattern, not fixed page counts.
- Store dates as ISO and flag day/month ambiguity under 13.
- Exclude statement summary pages and dedupe on invoice number.
- Entry pricing runs around $39/month for about 300 documents; 2,000/month needs a higher tier.
- No native splitting in the dashboard — the splitter is your code.
