Command line

One PDF, many PDFs or whole folders, to Markdown, plain text or JSON.

Terminal
khpdf [OPTIONS] <PDF_OR_FOLDER>...

Examples

Terminal
khpdf report.pdf                      # Markdown in the terminal
khpdf report.pdf -o report.md         # save it (the format follows the file name)
khpdf report.pdf -o report.txt        # plain text
khpdf report.pdf -o report.json       # structured JSON
khpdf *.pdf -o out/                   # many PDFs into a folder
khpdf docs/ -o out/ -r                # a whole folder, subfolders too
khpdf report.pdf --pages 1-3,5        # only some pages
khpdf report.pdf --inspect-fonts      # which fonts are inside, and how each is decoded

Options

OptionWhat it does
-o, --output PATHA file for one PDF, or a folder for several. A path ending in / is always a folder.
-f, --format md|txt|jsonOutput format. Without it, the output file's extension decides, else Markdown.
-p, --pages PAGESOnly these pages: numbers and ranges like 1,3-5.
-r, --recursiveAlso look for PDFs in subfolders.
--page-markersMark where each page starts.
--prettyIndent JSON for reading.
--wordsIn JSON, list every word with its box on the page. See The output.
-q, --quietPrint only errors.
--inspect-fontsShow each page's fonts and how khpdf decodes them, instead of the text. See Troubleshooting.
--no-normalizeKeep glyphs in the order the PDF stores them.
--no-legacyDo not decode Limon legacy fonts.

Where the results go

Messages and exit codes

Each saved PDF gets a one-line summary on stderr, and a batch ends with a total. Scanned PDFs are pointed out. Errors are explained in plain words (`nope.pdf` does not exist, not a readable PDF).

Exit codeMeaning
0Everything converted
1At least one PDF failed
2The command itself was wrong (unknown option, missing file name)