BBox
A rectangular region on a page, given by its four edges. It's the bbox field on Chunk, Block, Table, and TableCell.
A bbox is populated for PDF documents and for HTML rendered via Playwright (the default path, which lays the page out in a real browser). It is None for DOCX, PPTX, and HTML parsed on the fallback path when Playwright isn't installed — those routes carry no geometry.
for chunk in result.chunks:
if chunk.bbox is not None:
b = chunk.bbox
print(b.x_left, b.y_top, b.x_right, b.y_bottom)Coordinates
The origin is the top-left of the page and the y-axis increases downward, so y_top < y_bottom. Coordinates are in points (1/72 inch) for both PDF and HTML — the HTML pipeline converts rendered pixels to points so the units are consistent across formats.
| Field | Type | Description |
|---|---|---|
x_left | float | X coordinate of the left edge. |
y_top | float | Y coordinate of the top edge. |
x_right | float | X coordinate of the right edge. |
y_bottom | float | Y coordinate of the bottom edge. |
Coming from pdfplumber or similar tooling? The names map directly: x_left = x0, x_right = x1, y_top = y0, y_bottom = y1. DocSlicer uses the descriptive form so the edge each value refers to is unambiguous.
Width and height aren't stored — derive them from the edges:
width = b.x_right - b.x_left
height = b.y_bottom - b.y_topMethods
BBox.from_dict(d)
Reconstruct a BBox from a dict with x_left, y_top, x_right, and y_bottom keys. Returns None when d is None, mirroring how a missing box is represented on the parent object.
b = BBox.from_dict({"x_left": 72.0, "y_top": 90.0, "x_right": 540.0, "y_bottom": 120.0})