LM-Kit OneDocs2026.10.10lm-kit.comEULA
Intelligent Document Processing

Barcode Splitting and Reading

Mailrooms and scanning stations have marked documents with barcodes for decades: a separator sheet slipped between two documents, a cover sheet that names the file, a code stamped on every page of a claim. When the batch carries those marks, the split is a matter of READING them, not of interpreting the content. POST /lmkit/v1/barcode-splitting does exactly that, and POST /lmkit/v1/barcode-reading reads any barcode on any page. Both are deterministic image analysis: no model is loaded, the same batch always splits the same way, and a page costs milliseconds. For batches without marks, Intelligent Splitting finds the boundaries from the content.

Both endpoints read a PDF, a multi-page TIFF or an image, and every common symbology: QR Code, Micro QR, rMQR, Data Matrix, PDF417, Aztec, MaxiCode, Code 128, Code 39, Code 93, Codabar, ITF, EAN/UPC, DataBar, Telepen.


1What a barcode means: mode#

mode The barcode... Typical batch
SeparatorPage (default) stands on a sheet between two documents separator sheets printed once and reused
FirstPageOfDocument marks a document's first page, which stays in it cover sheets, stamped first pages
LastPageOfDocument marks a document's last page a closing slip after each document
ValueChange carries a value; a new document starts when it changes every page stamped with its file number
GroupByValue carries a value; all pages with that value form one document a mixed mailroom stack, pages out of order

With SeparatorPage, separator_handling decides what becomes of the sheet: Remove (default), KeepAsFirstPage or KeepAsLastPage. In a duplex scan the back of each separator is a blank page: remove_blank_page_after_separator: true drops it, and remove_blank_pages drops every blank page.

Pages no barcode accounts for (before the first one; after the last one in LastPageOfDocument mode) follow leading_pages: KeepAsDocument (default), Discard, or MergeIntoNearestDocument.

2Which barcodes count: match#

A batch carries more codes than the ones that split it: an invoice's EAN, a parcel label, a payment slip. match keeps them out:

"match": {
  "formats": ["QRCode"],
  "pattern": "^SEP-",
  "search_area": { "left": 0.6, "top": 0, "width": 0.4, "height": 0.25 }
}

formats (any case, separators ignored: QRCode, qr code, EAN-13; groups AllLinear, AllMatrix), exact values, a pattern, a search_area (fractions of the page: only that part is scanned, which is also faster) and a minimum_symbol_size. Barcodes found but rejected are still reported, in each page's ignored_barcodes, so a rule is tuned on a real batch instead of guessed.

3The value of a document#

The barcode that delimits a document gives it a value: its label, the key of ValueChange and GroupByValue, and its file name through {value} in file_name_template. value_pattern extracts it from a longer text:

"value_pattern": "CASE-(?<value>\\d+)"

4The response#

  • documents: each with start_page, end_page, its exact pages (not consecutive with GroupByValue or removed blank pages), value, label, the trigger barcode and every barcode on its pages; with split_documents: true, its file_id and file_name.
  • pages: every scanned page with its role (Content, Separator, KeptSeparator, BlankDiscarded, LeadingDiscarded), its barcodes and ignored barcodes.
  • separator_pages, discarded_pages, failed_pages: a page that cannot be read never splits the batch; it stays content and is listed here.

With split_documents: true, each document is stored as a PDF whose pages are COPIED from the source (text, fonts and vectors intact), or as a TIFF (output_format: "Tiff"; SameAsSource keeps a TIFF batch in TIFF). Chain the file ids into OCR, classification or extraction.

curl -s "$LMKIT_URL/lmkit/v1/barcode-splitting" \
  -H "Content-Type: application/json" \
  -d '{
    "input": "'"$FILE_ID"'",
    "input_format": "FileIdentifier",
    "mode": "SeparatorPage",
    "remove_blank_page_after_separator": true,
    "split_documents": true,
    "file_name_template": "{value}"
  }'

5Reading barcodes#

POST /lmkit/v1/barcode-reading returns, per page, each barcode's format, text, bytes_base64, bounds on the page (points for a PDF, pixels for an image) and orientation. Use it to route a document by its code, to inspect a batch before choosing a split rule, or to read labels, tickets and payment slips. formats and page_range narrow the work; dpi (default 200) can rise to 300 for small or dense codes.

6From agents#

The MCP server exposes the same two operations as document_read_barcodes and document_split_by_barcodes.