AI for Mixed PDF Packets: Checking Page Boundaries, Missing and Duplicate Pages Before Approved Posting

Using a fictional import packet scanned into a single PDF, separate classifying from splitting as Microsoft's custom classifier documentation describes, reconcile page ranges, catch missing and duplicate pages, and have a person approve before anything is posted, with acceptance conditions.

Published by Mentrix Digital ·

Article cover: AI for Mixed PDF Packets: Checking Page Boundaries, Missing and Duplicate Pages Before Approved Posting

Key points

  • Classification says what kind of document a page probably belongs to; splitting says where each document starts and ends. Configure and test them separately, because some tools do not split unless told to.
  • Before anything moves on, every page of the PDF belongs to exactly one document, ranges do not overlap, the page total matches the file, and missing or duplicate pages are raised as exceptions rather than silently filled or dropped.
  • AI proposes page ranges and document types, the system checks the rules, a person reviews and approves before posting, and the original file is kept unaltered.

One PDF, several documents and pages that do not add up

A fictional food-ingredient importer receives an email from its customs broker for every shipment, with a single PDF that scans everything together: the supplier's commercial invoice, the packing list, the bill of lading, the certificate of origin and the broker's own service invoice. Some packets contain commercial invoices from two suppliers in the one file. Accounts has to separate these to record landed cost. The recurring problems: page two of an invoice scanned twice, the last page of a packing list missing, and a printed email cover page mixed into the file. This is a hypothetical scenario, not client work.

This differs from extracting fields from a document whose type is already known, where the question is whether an amount or invoice number is right. Here you first have to answer how many documents the file holds, which pages each one covers, and whether any pages are missing or extra. If the page boundaries are wrong, even perfectly accurate field extraction reads from the wrong document: an amount on a duplicated page two might be counted twice.

Once documents are split correctly, setting confidence thresholds for each extracted field is covered in the per-field confidence threshold guide →

Classifying and splitting: two jobs to configure separately

The Azure AI Document Intelligence documentation on custom classification models explains that a custom classifier classifies an input file one page at a time and can identify multiple document types, or multiple instances of the same type, within one file. The response contains the page ranges of each document found, with a confidence score. The catch: in the v4.0 2024-11-30 API the classifier does not split by default. The default splitMode is none, which returns one class for the whole file; for files containing several documents you set it to auto so the service identifies documents and their page ranges, while perPage classifies each page as an individual document.

The same page states that training needs at least two distinct classes and at least five samples per class, and that the classifier attempts to assign every document to one of its trained classes. If you expect document types it was not trained on, set a threshold on the classification score or add an “other” class with samples of unwanted documents, such as email cover pages. These figures and settings can change between versions, so check the current documentation for the version you actually use. The principle carries over to other tools: whichever provider you choose, ask the developer three questions. Does the system split documents or only classify them? Does the output include page ranges? Where do documents outside the trained types end up?

If you want an AI system that splits and classifies mixed PDF packets, with a screen for people to check page ranges, see Custom AI Solutions for Business →

Analyst checking a scanned document field with a magnifier
Check pages the classifier scored low against the scan, such as an email cover page that belongs in other, not with an invoice.

Reconciling page ranges: every page in exactly one document

AI output is a proposal. The system checks it against written rules before any person sees it. None of these rules needs AI: plain code can check them, and they give the same answer every time. Take a fictional 12-page packet where AI proposes: page 1, email cover (other); pages 2–4, commercial invoice INV-A; pages 5–6, packing list; page 7, bill of lading; page 8, certificate of origin; pages 9–10, broker's invoice; pages 11–12, commercial invoice INV-B. The rules find that page 4 is the same image as page 3, with the footer “2/2” repeated, and that the packing list has pages “1/3” and “2/3” but no “3/3”. The packet is marked “needs review” with two exceptions, even though AI gave every range a high confidence score.

  • Every page from 1 to the last page of the file sits in exactly one range: no page left out, no overlapping ranges, and the page counts add up to the file's page count.
  • Printed page numbers such as “2/3” run in sequence and are complete. If a document has no page numbers, record that this check could not be made; it does not count as a pass.
  • A page whose image or text almost entirely matches another page is raised as a duplicate but never removed automatically. A person confirms whether it is a true duplicate or a copy attached on purpose.
  • The document number on every page of one document must match. Different numbers, such as INV-A and INV-B, mean two documents.
  • The packet contains every required type on the checklist for that kind of import, such as commercial invoice, packing list and bill of lading, with the certificate of origin required when a tariff preference is claimed.
  • Pages classed as other, or scored below the threshold, are never merged automatically into a neighbouring document.
Three distinct invoice, purchase order, receipt sheets matched at desk
Lay the split documents side by side and count their printed page numbers to find the missing 3/3 and the repeated 2/2.

People check the ranges and approve before posting

The review screen shows thumbnails of every page in file order, grouped by the proposed ranges, with exception labels on the pages concerned. An accounts reviewer can move boundaries, change document types and confirm duplicates, and every edit records who changed what, from which value to which. Pages confirmed as duplicates are left out of the documents used for posting but stay in the original file. The broker's original file is kept unaltered; each split document is a new file that refers back to its page range in the original.

When a page is missing, the system drafts a request to the broker, such as “Please send page 3/3 of the packing list for packet …”, which the reviewer reads and sends. The packet waits in an awaiting-documents state until the page arrives; nothing is posted in part. Landed cost is posted to the accounting system only after an authorised person approves the packet. Neither AI nor the automation has permission to post. If the AI service is unavailable, the reviewer splits pages by hand on the same screen and the range checks still run.

If you want the inbox, review screen and accounting system connected so that only approved packets can be posted, see Automation & Business Software →

An overview of document intake with human review before use is in the AI document intake guide →

Office manager approving a document at a desk
The approver signs off the packet only once every exception is closed, and only then is landed cost posted.

Acceptance conditions agreed before seeing results

Build the test set from past packets with unnecessary data removed. Each has an answer key, made by accounts, of which pages each document covers. The test set must not overlap with the training data, and it must include hard cases in deliberate proportions: duplicate pages, missing pages, two invoices in one file, pages scanned upside down, untrained document types and packets from a broker not seen before. The process owner, the developer and the head of accounts agree and date the conditions below before the run. Failing any one is a fail:

  • Every page in the test set sits in exactly one range, 100%, with no omitted pages or overlaps in the output that reaches reviewers.
  • Every packet with a missing or duplicate page in the answer key is raised as an exception; no packet is marked “complete” while something is missing or extra.
  • Document start and end pages match the key, measured separately by document type and for the unseen-broker group, against minimums for each set before the run.
  • Documents outside the trained types go to other or to a reviewer, and are never classed as a commercial invoice.
  • With the AI service switched off during testing, reviewers can still split pages by hand and the range checks still run.
  • No posting arises from an unapproved packet, checked against the test accounting system's log.
  • The model version, the splitMode or equivalent setting, the score threshold and the test set version are recorded with the results, for comparison when versions change.

If you want acceptance conditions for a document AI system agreed with management before commissioning development, see AI Strategy & Consulting →

When the provider changes the model or API version, rerunning the same test set to compare versions is covered in the model upgrade regression test guide →

Measuring after go-live: boundary corrections and posting reversals

The measures that show whether the system really helps are: the share of packets where reviewers corrected page boundaries, by broker; time from email receipt to approval; the number of missing-page requests; and the number of postings reversed because the wrong document or a duplicate page was used. The last matters most, because it is an error that got past AI, the rules and the reviewer. If even one occurs, add that packet to the next test round.

The following figures are a hypothetical example to show how to read the results, not results from a real system. Suppose the first month has 80 packets and reviewers correct boundaries in 14, or 14 ÷ 80 = 17.5%. Nine of those come from one broker who scans two pages per sheet. That does not mean the model got worse; it means that broker's file format is not yet in the training data. The fix is to send that broker's packets for full page-by-page review for now, add samples for further training and retest on the held-out set, never to lower the threshold to make the figure look better.

Sources

  1. Vendor documentation · Microsoft Learn: Custom classification model – Document Intelligence (v4.0) · Accessed

Want help applying this?

Tell us about your situation and we will suggest a scoped next step. We do not promise specific rankings, leads or revenue.

Discuss your project

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.