@layoutor/cli
v1.0.1
Published
CLI for Layoutor's PDF layout-preservation and text-rewrite service
Readme
@layoutor/cli
Command-line access to Layoutor for Node.js 20 and newer. Layoutor is a layout-preservation service, not a translation engine: it extracts a PDF's text as units for you or your model to rewrite, then re-typesets your submitted text so the PDF looks like the original. Use it for register or tone changes, simplification, correction, glossary application, or translation. Layoutor never writes, translates, or judges text itself; --to names the language of the text you submit, including the source language for same-language edits.
Install
npm install --global @layoutor/cliSet an API key. LAYOUTOR_API_KEY takes precedence over --key when both are present.
Credentials must be lk_live_ followed by exactly 43 URL-safe characters (A-Z, a-z, 0-9, _, or -).
Every other value, including the empty string, produces invalid_credentials; an unspecified credential produces
missing_credentials.
export LAYOUTOR_API_KEY="your-api-key"The CLI package depends on @layoutor/sdk 1.0.1. The repository lockfile links the sibling SDK during development.
To use an alternate API endpoint, pass --base-url <url> as a global option or set LAYOUTOR_BASE_URL. The option takes precedence over the environment variable. Plain HTTP is accepted only for loopback URLs.
layoutor --base-url http://127.0.0.1:3000 whoamiCommands
Extract JSON units (add --xliff for XLIFF):
layoutor units input.pdf --to ja --from en -o units.jsonSubmit translated units and compose a PDF:
layoutor compose doc_123 --translations units.ja.json -o output.pdfRun upload, extraction, submission, and composition in one command:
layoutor translate input.pdf --to ja --translations units.ja.json -o output.pdfInspect or delete a document and inspect the authenticated account:
layoutor status doc_123
layoutor delete doc_123
layoutor whoamiOutput files are not overwritten by default. Add --force to units, compose, or translate to replace an existing output file.
--help before a -- option terminator takes precedence over credentials and other argument validation. After --, every token is positional: the first is the command name when the terminator precedes the command, and later tokens such as --help are passed literally as command arguments. Add --json to any command for one machine-readable success object on stdout. Errors are written only to stderr. Progress is shown as one updating stderr line only when stderr is a TTY; JSON mode suppresses it.
Success and failure output replaces every exact occurrence of the accepted credential, even inside a larger identifier. It also replaces every string matching lk_live_ followed by 43 URL-safe characters. Key-shaped non-credential text is therefore redacted as an intentional false positive. Error codes are not redacted.
Exit statuses:
| Status | Meaning |
| ---: | --- |
| 0 | Successful command or help output. |
| 2 | Invalid arguments, missing or invalid credentials, local file or PDF failure, invalid JSON/XLIFF/translation shape, or an existing output path without --force. |
| 3 | SDK or API failure, invalid API base URL, network or invalid-response failure, terminal document failure, or an unexpected internal error. |
