Skip to content

CLI reference

@pardown/cli provides the pardown command for converting one Markdown file or standard input into a PDF. This page documents installation, path handling, output behaviour, warnings, and exit statuses.

Install the CLI

Install the package globally to add pardown to your command path.

sh
npm install --global @pardown/cli
sh
pnpm add --global @pardown/cli
sh
yarn global add @pardown/cli

The package runs as an ECMAScript module on Node.js. Its package metadata doesn't declare a minimum Node.js version.

Convert a file

Pass exactly one Markdown file path. Without an output option, Pardown replaces the input's final extension with .pdf and writes the result beside the input.

sh
pardown notes.md

For example, notes.md becomes notes.pdf, notes.draft.md becomes notes.draft.pdf, and README becomes README.pdf.

Relative image paths resolve from the input file's directory. Pardown reads the complete input as UTF-8 before starting conversion.

Set the output path

Use --output or -o to choose the PDF path. A relative output path resolves from the directory where you run the command, not from the input file's directory.

sh
pardown notes.md --output exports/meeting-notes.pdf
pardown -o exports/meeting-notes.pdf notes.md

The output's parent directory must already exist.

WARNING

Pardown overwrites an existing output file without asking for confirmation.

Read from standard input

Use - as the input to read UTF-8 Markdown from standard input. Relative images then resolve from the directory where you run the command.

sh
printf '# Meeting notes\n' | pardown - --output meeting-notes.pdf
cat notes.md | pardown -o exports/meeting-notes.pdf -

If you omit --output, Pardown writes stdin.pdf in the current directory. The command buffers all standard input before conversion and doesn't write PDF bytes to standard output.

Command syntax

The command accepts one input and two options.

text
Usage: pardown [options] <input|->

Convert a Markdown file to PDF. Use - to read Markdown from stdin.

Options:
  -o, --output <file>  Output PDF path (default: input name or stdin.pdf)
  -h, --help           Show this help message

Use -- before an input filename that starts with a hyphen:

sh
pardown -- --draft.md

The CLI doesn't provide a version option, batch conversion, or PDF output through standard output.

Warnings and errors

Recoverable conversion diagnostics are written to standard error with a warning: prefix. An image-loading warning renders alternative text in place of the image, and an unsupported-node warning keeps supported descendant content.

Argument, input, conversion, and output failures are written to standard error with an error: prefix. Argument errors also print the command help.

Successful conversion doesn't print progress or a success message.

Exit statuses

The process uses one of two exit statuses so scripts can detect success or failure:

  • 0 means help was displayed, or conversion and file writing completed.
  • 1 means argument parsing, input reading, conversion, or output writing failed.

Warnings alone don't change a successful exit status.

Examples

These examples cover common CLI workflows.

Convert a document beside its Markdown source:

sh
pardown handbook.md

Write the PDF to an existing export directory:

sh
mkdir -p exports
pardown handbook.md -o exports/team-handbook.pdf

Convert generated Markdown from another command:

sh
printf '# Build result\n\nAll checks passed.\n' | pardown -o build-result.pdf -

Check the status in a shell script:

sh
if pardown handbook.md -o handbook.pdf; then
  echo 'Created handbook.pdf'
else
  echo 'PDF conversion failed' >&2
  exit 1
fi

Next steps

Read Markdown support to check how document elements render. Use Image loading and cancellation or Diagnostics when you need control that the CLI doesn't expose.

Released under the MIT License.