Skip to content Enterprise Perfect Docs Guaranteed — a per-field accuracy SLA in your contract. You only pay for documents we get right. Learn more
Cover illustration for “How to split a merged PDF into separate documents at scale: boundary detection, classification and extraction for files with hundreds or thousands of pages”
AI/Tech Explainer

How to split a merged PDF into separate documents at scale: boundary detection, classification and extraction for files with hundreds or thousands of pages

Ignacio Gabaldón Ignacio Gabaldón 9 min read
Table of contents

Splitting a merged PDF reliably takes more than cutting it into smaller files. It requires four connected stages, which are boundary detection, splitting, classification, and extraction. Those stages need asynchronous processing, complete page accounting, and confidence checks at both document and field level. Without those controls, a successful job can still deliver the wrong documents and the wrong data.

Why splitting a merged PDF is an engineering problem, not a preprocessing step

A mailroom scanner turns a stack of unrelated documents into one PDF. That file is a transport container. Accounts payable teams need the invoices inside it, while mortgage and insurance teams need contracts, annexes, and supporting records kept in their correct groups. The first task is therefore to recover the documents that the upload obscures.

Errors at this stage travel through the pipeline. A boundary error at page 12 of a 500-page file can corrupt the grouping of documents that follow. Invofox is a document extraction API that turns invoices, contracts, and similar documents into validated JSON, but extraction inherits whatever the split produces. The DocSplit benchmark reports clustering accuracy ranging from 0.56 to 0.90 across document collections. That spread shows why the files produced by splitting still need to be checked.

What boundary detection must read and why rule-based approaches break at scale

Letterhead, page numbering, and a change of subject can suggest a new document, but none settles the question alone. A contract annex may change format while still belonging to the contract. But two invoices next to each other may have the same layout. A rule that relies on a change in how pages look will struggle with the first case, while one that relies on pages looking the same will struggle with the second.

Fixed templates break down on mixed or unfamiliar batches because the pages no longer fit what the templates expect. Model-driven detection removes that template dependency, though it still needs enough evidence to distinguish continuation from a new document. Some relationships are not visible on the pages. Optional domain-guidance strings can express those relationships, while custom schemas and continuous learning from corrections offer another way to improve handling of new document types. Invofox supports those latter capabilities without requiring a fixed ruleset to be rewritten for every change.

How LLM-based boundary detection works and where its efficiency limit sits

Zero-shot LLMs can find boundaries without task-specific training. That removes one setup burden, but it does not remove the cost of reading a long file. Standard Page Classification and Boundary Decision formulations resolve one candidate boundary per model call. Requests therefore grow linearly with file length. For a large batch, the way the model is asked to make decisions becomes an engineering constraint of its own.

The paper identified as arXiv:2609.22620, accepted at the DocInsights Workshop at EMNLP 2026, describes Multi-Split Boundary Decision. This approach predicts several boundaries in one page window with each call, so it needs fewer inference requests. Larger windows are not an unlimited shortcut, however. Accuracy drops sharply beyond the optimal window range, so window size must be tuned for the document collection.

Splitting, classification, and extraction as a chained pipeline — and why classification cannot wait until after splitting

Classification can run after the files have been split. It cannot be an afterthought in the pipeline design. Each segment needs a document type before extraction can map it into the right typed JSON Schema. The DocSplit benchmark treats boundary detection and type classification as simultaneous requirements, particularly in heterogeneous batches. The two operations can meet that requirement while running at different times.

Physical splitting belongs on the server, so the client does not have to manipulate PDFs, track page ranges, or send the same bytes twice. Invofox enables its Splitter through useSplitter:true in the upload’s info field. Each split is named split_n.pdf, using a 1-based index. The import.info.splitter object contains a signed URL to the original PDF, page ranges, and the total split count as an integer. Upload-level clientData propagates to every sub-document without additional API calls.

For combined splitting and classification, the API accepts useClassifier:true with useSplitter:true. Omitting type lets the classifier determine each segment’s document type. Extraction then produces typed JSON with per-field confidence linked to evidence in the source. Markdown conversion and search indexing can consume the same file ID rather than create separate copies of the pipeline’s document boundaries.

Why files of hundreds or thousands of pages require async processing, not a single blocking call

A large batch cannot reasonably complete all four stages within a typical HTTP request timeout. Time is not the only constraint, either. A 500-page file that mixes high-resolution scans with native PDFs can need more peak memory than a synchronous handler can safely use. A single blocking call also makes it harder to preserve successful work when some segments fail. Asynchronous processing separates accepting the upload from completing the work.

The upload therefore returns an importId immediately. Completion then has two meanings, which the integration must distinguish. The import.processed event shows that the batch is done, while document.processed lets results stream through as each document finishes. Without push delivery, the client can poll GET /v1/ingest/imports/{importId} until the import reaches processed status. Invofox states that its import limit is 100 MB per file and rejects larger uploads through HTTP 413.

Completeness validation — ensuring every page is accounted for exactly once

A completed job can still contain missing, duplicated, or orphaned pages without raising a processing error. Completion is not proof of complete coverage. Completeness validation must reconcile the original upload against the split manifest so that every source page has exactly one accounting entry. Blank pages and separator pages must remain visible in that tally. Otherwise, an apparently harmless omission cannot be distinguished from a page lost during processing.

A split can physically contain a scanned page whose OCR produced no usable content. Its page range may therefore be correct even though extraction has nothing useful to read from part of the document. Mixed scanned and native pages make this distinction especially important because physical presence says nothing about readable content. The accounting check establishes where the page went, while the content check establishes whether the pipeline could use it.

Failure modes that compound across stages — scan quality, layout variation, and hidden text

Poor input can damage more than one stage. A low-resolution page with a diagonal watermark and running headers can garble identifiers during OCR while extraction still reports completion. Layout ambiguity can also confuse the boundary decision before extraction begins. Invofox’s hybrid PDF pipeline uses native text extraction when a page has a text layer and a vision model for scanned pages. Even with these ways to read different page formats, a job can finish with the content read wrong.

The study arXiv:2606.15020, submitted to IEEE S&P 2027, describes split-view PDFs in which the extracted text differs from the rendered page. Its four gap families are semantic overrides, hidden semantic injection, reading-order splits, and font-decoding splits. Every LLM service tested had at least one gap. Exposure was shaped primarily by the ingestion stack, so the risk cannot be judged from the extraction model alone. Hidden instructions in an adversarial invoice can reach the model through content that differs from what a reviewer sees.

Extracted text and the rendered page must be considered together rather than trusting either reading path without comparison. Schema-version tracking addresses a different source of failure, where changes in the expected extraction structure introduce drift. These controls serve different purposes.

Per-document confidence and per-field accuracy as the production reliability signal

Confidence is useful only when it predicts correctness. Boundary confidence asks whether the pages belong together, while field confidence asks whether a value read from them is right. Those are different decisions and need separate evidence. A well-read field does not prove that its page belongs to the right document. Likewise, even when the pages are grouped correctly, an identifier or amount may have been extracted wrong.

Raw vision-language model confidence is poorly calibrated at high selectivity thresholds. A high score on a split-view PDF is especially dangerous because the model may confidently read content the reviewer cannot see. ExtractConf’s analysis finds that a 40-feature confidence model substantially outperforms raw signals at the same selectivity target. It uses OCR confidence, how well two extraction calls agree, layout features, and image sharpness together.

Commercial accountability is a separate part of reliability. On Enterprise plans, Invofox’s per-field SLA means the customer pays only for pages extracted correctly. An accuracy commitment places risk on the vendor rather than leaving the customer to absorb the gap between a benchmark claim and production results. It gives the accuracy claim a consequence when the delivered extraction is wrong.

What the pipeline looks like end-to-end for a production deployment

Post the merged PDF with useSplitter:true in info, adding useClassifier:true and omitting type for mixed batches. Save the returned importId so the batch can be tracked independently of the upload request. Use import.processed as the authoritative batch-completion event, or poll the import endpoint when push delivery is unavailable. Events for each document can give results earlier, but they do not show that the whole upload is done.

Before releasing results, check the page ranges against the original file. Gate ambiguous splits on document confidence, then apply per-field thresholds calibrated to the document class. These checks belong at different points because uncertainty about grouping and uncertainty about a value are not interchangeable. Retry only failed documentIds so that successful work stays done. Audit logging should support continuous learning from corrections, with the retention posture defined as part of the deployment.

Invofox’s zero-retention page states that documents arrive over TLS into an isolated processing chamber with no disk persistence and are cryptographically erased after delivery. Zero retention is opt-in, on Scale and Enterprise plans. The business retains structured JSON as its extraction record. No original file remains at the processing layer under that stated posture. That makes the retained record and its audit trail important parts of the handoff.