docx command.
npx docx pdf input.docx -o output.pdf
npx docx png input.docx -o pages/ --pages 1-3 --scale 2
npx docx json input.docx -o layout.json
Commands
| Command | Does |
|---|---|
docx pdf <file> | Writes a PDF |
docx png <file> | Writes one PNG for each page into a folder |
docx json <file> | Writes the layout IR (pages, lines, runs, boxes) as JSON |
docx blocks <file> | Writes semantic blocks (headings, paragraphs, tables, figures) with page boxes. For RAG and extraction. See Blocks and citations |
docx read <file> | Prints a text sketch of each page |
docx text <file> | Prints the document text |
docx find <file> <needle> | Finds text and prints its address |
docx edit <op> <file> | Applies one edit. Writes the input in place unless you pass -o |
Common flags
| Flag | Notes |
|---|---|
-o, --out | Output file (pdf, json) or folder (png) |
--pages 1,3,7-9 | Pages to paint (png) |
--scale K | PNG scale. Default 2 |
--max-pages N | Stop layout after N pages |
--tracked-changes final|inline|balloons | Print the final view (default), show insertions and deletions inline, or show deletions and formatting changes in margin balloons |
--comments hidden|balloons | Hide comments (default) or show them in a margin |
--page-color print|screen | White page as Word prints (default), or the document’s page colour |
npx docx --help for every flag.
Examples
Print a redline PDF with comments:npx docx pdf contract.docx -o contract-redline.pdf --tracked-changes inline --comments balloons
for f in docs/*.docx; do npx docx png "$f" -o "thumbs/$(basename "$f" .docx)" --pages 1 --scale 0.5; done