#CLI
The npm package includes a clawpdf command for shell and agent workflows.
npm install clawpdf
#Extract Text
clawpdf report.pdf
cat report.pdf | clawpdf -
The default command is shorthand for clawpdf extract and prints extracted text to stdout. Diagnostics and errors go to stderr.
#JSON Output
clawpdf report.pdf --json
clawpdf extract report.pdf --mode both --pages 1,3-5 --json
JSON output uses a stable shape:
{
"text": "...",
"pagesProcessed": [1],
"truncated": { "text": false, "images": false },
"images": [
{
"page": 1,
"width": 800,
"height": 1000,
"mimeType": "image/png",
"base64": "..."
}
]
}
#Render One Page
clawpdf render report.pdf --page 1 > page.png
clawpdf render report.pdf --page 1 -o page.png
clawpdf render report.pdf --page 1 --inline auto
Rendering writes PNG bytes to stdout unless -o, --output is provided. Use --inline auto|kitty|iterm|none to render the page in supported terminals instead of writing binary PNG bytes to stdout.
#Common Flags
--mode auto|text|images|bothselects extraction behavior.--pages 1,3-5selects one-based pages for extraction.--max-pages,--max-text-chars, and--min-text-charsset extraction limits. The CLI caps extraction at 20 pages unless--max-pagesis set, and rejects page lists above 100,000 pages.--dpior--scalecontrols image size.--max-pixelsand--max-dimensionbound fallback image output.--formsand--no-formscontrol form rendering.--password <value>or--password-file <path>opens encrypted PDFs.--output-dir <dir>writes extracted fallback images aspage-N.png.--inline auto|kitty|iterm|nonerenders extracted or rendered PNGs inline in supported terminals. It is not supported with--json.
#Exit Codes
0: success.1: runtime extraction or rendering failure.2: invalid usage or flags.3: input could not be read or parsed as a PDF.4: password is missing or incorrect.5: render or extraction budget exceeded.