01

What the broken text looks like

The first line of the left column is followed by the first line of the right column. Both sentences are cut in half. A search index still counts the words as present.

A model asked to summarize that string will often invent a connection between the two halves.

02

Regions before lines

Find the columns from gaps, gutters, and text alignment. Assign each glyph or line to a region. Order the regions the way a reader moves, then order the lines inside a region.

Headers, footers, and page numbers are their own regions. They should not be inserted into the paragraph they happen to sit beside.

03

Prove it with one question

Write a question whose answer sits only in the second column, and a question that is wrong if the columns are interleaved.

Store the block order in DocIR. The Markdown should follow that order so the readable view and the structured view agree.

04

How the text-layer order is chosen

The PDF text-layer path orders word boxes with a column-first XY-cut. It splits a region at a full-height vertical gutter before it splits a full-width horizontal gap, then reads the left part before the right part. Full-width titles stay in their own band.

Upright words are kept. Rotated margin text, including sidebars and watermark strips, is excluded so it does not become a fake first column. The document warning says rotated margin text was excluded from output.

Check the cut with two sentences on one page. The left column says Revenue grew in the platform segment. The right column says Services grew more slowly. A top-to-bottom sort mixes them into Revenue grew in the Services grew platform segment. more slowly. The column-first cut emits the whole left sentence, then the whole right sentence. pages[].blockIds follows that second order. Do not sort every line by vertical position alone. Index only after the left sentence is whole, then check the right sentence. Full-width titles stay in their own band. The exact exclusion warning is Rotated margin text (sidebars/watermarks) was excluded from output.

  • pages[].blockIds is the reading order for that page.
  • A block's pageIndex must match the page that lists its id.
  • Ask one question that is true only if the left column is whole.
  • Ask a second question that is wrong if the columns are interleaved.
05

The file to send

Send a two-column text-based PDF. Pick a sentence that appears only in the left column and confirm result.markdown keeps it whole.

The text-layer order is column-first. Rotated margin text is excluded, with the warning Rotated margin text (sidebars/watermarks) was excluded from output. A full-width title stays in its own band.

  • Follow pages[].blockIds.
  • Ask for a fact that sits only in the second column, then find that fact in the Markdown.
  • pageIndex 0 is the first page of the file.
export DOCPARSE_URL="https://docparse.genedai.me"
export DOCPARSE_API_KEY="your_key"

curl -fsS -X POST \
  "$DOCPARSE_URL/v1/parse?wait=true" \
  -H "Authorization: Bearer $DOCPARSE_API_KEY" \
  -F "file=@document.pdf" \
  -F "mode=both" \
  -o result.json

jq -r '.result.markdown' result.json
jq '.result.document.schemaVersion, .result.document.pages[0].blockIds' result.json
jq '.result.manifest.decision.route, .result.manifest.parserVersion' result.json

Frequently asked questions

Questions this guide answers

Why do two columns come out interleaved?

The lines were sorted by vertical position and the gutter was ignored. The text-layer path uses a column-first XY-cut so the left column is emitted before the right column.

Should headers and footers stay in the paragraph?

Repeating page furniture should stay out of the body. Rotated margin text is already dropped on the text-layer path, with a warning that it was excluded.

How do I see the order DocParse used?

Read pages[].blockIds in docir.v1. That list is the reading order. The Markdown follows the same block sequence, and metadata.route names the path.