PDFs do not contain the clean document tree that HTML does. @boxpdf/reader
uses the page layout to put content back into a useful reading order, with paragraphs,
tables, nested sections, cards, addresses, labels, and values.
Reading orderParagraphs and linesTable structureSource coordinates retainedAccessible HTMLLLM-ready context
The designed page on the left. Its document flow on the right.
Choose a real PDF. The browser renders its original pages on the left while boxpdf turns the same document into reflowable headings, paragraphs, lists, cards, address groups, totals, and tables on the right.
Visual PDFbrowser renderer · scrollable
Semantic HTMLreflowable document structure
—open
—semantic HTML
—pages structured
—peak reader cache
Loading the semantic comparison…
The important distinction
Keep the page layout before simplifying it.
Text stored next to each other in a PDF may belong to different columns. Text stored far apart may belong to the same sentence. boxpdf looks at where content appears on the page before deciding how it should read.
visual
Preserve what the author placed
Coordinates, baselines, font metrics, vectors, images, clipping, transforms, and paint order remain available. The output can be rendered and compared to the PDF.
Best for viewers and previews
Best for visual LLM input
Keeps the layout needed to build semantic HTML
semantic
Produce HTML that reads naturally
boxpdf orders the text, groups related content, builds real tables, removes repeated headers and footers, and keeps sections and continued tables together across pages.
Best for accessibility and search
Best for extraction and indexing
Best for compact language-model context
How it works
Read the PDF. Rebuild the page. Produce useful HTML.
The semantic output keeps links to the original text and page coordinates. You can highlight the source, show the matching page, or let an LLM check the result against the visual document.
Use the right representation for the next job.
Accessible reading order
Turn positioned content into headings, paragraphs, lists, and tables that assistive technology can navigate.
Grounded LLM extraction
Send compact semantic content for reasoning and retain visual HTML for layout-sensitive verification and citations.
Search and indexing
Index coherent blocks instead of isolated glyph runs, while preserving page and bounding-box provenance for every result.
Tables and forms
Recover real rows, continued tables, totals, addresses, cards, labels, and values that plain-text extraction cannot keep connected.
Same extraction, different intent
Choose semantic output when meaning matters most.
import { blobSource, openPdf } from "@boxpdf/reader";
import { writeHtmlDocument } from "@boxpdf/html-writer";
const pdf = await openPdf(await blobSource(file));
await writeHtmlDocument(pdf.pages(), write, {
profile: "semantic",
semanticLookaheadPages: 4
});
Semantic output streams with bounded lookahead, so cross-page structure improves without turning a large document into a large memory spike.