PagesApi.boxes()
The page's MediaBox / CropBox / BleedBox / TrimBox / ArtBox, read without loading it.
methodReadingsince 1.0.0
Signature
boxes(pageIndex: number): Promise<PageBoxes>
Parameters
| Parameter | Type | Description |
|---|---|---|
| pageIndex | number | Zero-based page index. |
Returns
Promise<PageBoxes> { mediaBox, cropBox, trimBox, bleedBox, artBox }, every box a Rect in page space, resolved as a reader resolves it: the MediaBox is the full sheet (US Letter when the file has none); the CropBox is what renders (the MediaBox when the file declares none); the TrimBox, BleedBox and ArtBox fall back to the CropBox.
Throws
INVALID_ARGUMENT— a page index out of range.DOCUMENT_CLOSED— the document has been closed.
Example
TypeScript
const { cropBox } = await doc.pages.boxes(0); console.log(cropBox.width, cropBox.height); // points