A bigger font is a clue, not a label
The file may not contain an outline entry for every section. Size, weight, and spacing suggest a heading. The parser still has to decide the level.
If every bold line becomes a heading, captions and table headers pollute the outline. If none do, the Markdown is a flat run of paragraphs.
Use the outline as chunk boundaries
A section heading plus the paragraphs under it is the natural unit for retrieval. Split further only when that section is too long for the model.
Store the heading path on the chunk. A citation that says which section and which page is checkable. A bare sentence is not.
Compare the outline with the page
Open the PDF beside the Markdown. The heading stack should match the sections you see, including nested headings.
DocIR blocks can mark the heading type. The Markdown projection should use the same order.
How a text-layer line becomes a heading
On the PDF text-layer path, a line longer than 180 characters is not a heading. Abstract, References, Acknowledgements, and Appendix match as headings. A line that starts with a dotted number, such as 1.2, matches as a heading.
Otherwise the line is a heading when its largest font is at least 1.35 times the page median, or when it is bold and at least 1.12 times that median. An unnumbered heading is Markdown level 1. A numbered heading's level is the count of dots plus 2, capped at 6, so 1 Introduction is level 2 and 1.2 Scope is level 3.
This path does not read PDF bookmarks as the heading list. A line of 181 characters or more stays a paragraph even when it is bold. 1 Introduction becomes a level-2 heading. 1.2 Scope becomes a level-3 heading. Chunk on those heading blocks, not on a bookmark that the file may also contain.
- Chunk on block.type === heading, then keep the following paragraphs with it.
- A table caption that starts with Table plus a number is not a section heading.
- A bold table header should stay inside the table block.
- Compare the Markdown hashes with the page before you trust the outline.
The file to send
Send a text-based PDF with a numbered heading such as 1 Introduction and a nested heading such as 1.2 Scope. 1 Introduction is level 2. 1.2 Scope is level 3.
A line longer than 180 characters is not a heading. This path does not read PDF bookmarks as the heading list. Chunk on the heading blocks in pages[].blockIds.
- Abstract, References, Acknowledgements, and Appendix can match as headings.
- A Table caption that starts with Table plus a number is not a section heading.
- Compare the Markdown heading stack with the page.
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
Does PDF store headings as headings?
Some files have an outline. On the text-layer path DocParse infers a heading from the line text, a dotted section number, or font size and bold weight against the page median. The block type is heading and the Markdown uses that level.
Why do chunks ignore sections?
They were cut by token count before heading blocks existed. Parse first, then start a chunk at each heading block and keep the paragraphs that follow it.
Should a table header become a Markdown heading?
Keep a cell label inside the table block. A line is a heading only when the text-layer rules above match. A table caption that begins with Table and a number is classified as a table caption.