Use these command-line examples for common PDF to Text tasks. See the CLI guide for installation, input and output handling, and diagnostics.
You can run the examples below without account setup. The CLI uses demo credentials unless you have configured your own API credentials. Update the input URLs and filenames as needed.
Commands use POSIX-shell syntax, as in Bash or Zsh, and save results in the current directory.
These commands save the result with --output. See Handle the Result for output choices and failure handling.
Upload an existing invoice.pdf file.
pdf2text --output invoice.txt \ invoice.pdf
pdf2text --output invoice.txt \ https://your-server.com/invoice.pdf
Read invoice.pdf through stdin. Use the same - input for bytes piped from another program.
pdf2text --output invoice.txt \ - < invoice.pdf
These examples upload extraction.pdf, a three-page document with a two-column article, wrapped paragraphs, and invoice fields.
Extract pages 1 and 3 of extraction.pdf into excerpt.txt.
pdf2text --print-page-range=1,3 \ --output excerpt.txt \ extraction.pdf
Extract the article on page 1 into article.txt without spacing that recreates the PDF's columns. For tables, the default layout mode usually preserves column alignment better.
pdf2text --no-layout \ --print-page-range=1 \ --output article.txt \ extraction.pdf
Extract page 2 into paragraphs.txt, joining wrapped lines with paragraph detection and removing line-end hyphens. For example, infor- followed by mation becomes information. Paragraph detection depends on the document's layout.
pdf2text --paragraph-mode=bounding-box \ --print-page-range=2 \ --remove-hyphenation \ --output paragraphs.txt \ extraction.pdf
Crop away the headers and footers on every page, or extract only the customer, invoice, and reference fields on page 3.
The coordinates below match a 612 × 792 point (US Letter) page. Measure X and Y from the top-left corner; 72 points equal one inch. Adjust the regions for your PDF.
pdf2text --crop-area-height=648 \ --crop-area-width=540 \ --crop-area-x=36 \ --crop-area-y=72 \ --output body.txt \ extraction.pdf
pdf2text --crop-area-height=70 \ --crop-area-width=300 \ --crop-area-x=36 \ --crop-area-y=290 \ --print-page-range=3 \ --output fields.txt \ extraction.pdf
The default output has no page separators. Insert form-feed characters (\f) for processing text by page, or add a visible --- PAGE BREAK --- marker on its own line.
pdf2text --page-break-mode=default \ --output pages.txt \ extraction.pdf
pdf2text '--custom-page-break= --- PAGE BREAK --- ' \ --page-break-mode=custom \ --output separated.txt \ extraction.pdf