PDF to Text HTTP API Examples

These examples demonstrate common PDF to Text API workflows via HTTP API.

You can run the examples below with the displayed API credentials. Update the input URLs and filenames as needed.


Basic examples

PDF file to text file

curl -f -s -S \
  -u 'demo:demo' \
  -o invoice.txt \
  -F file=@invoice.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  https://api.pdfcrowd.com/convert/24.04/

PDF url to text file

curl -f -s -S \
  -u 'demo:demo' \
  -o invoice.txt \
  -F url=https://your-server.com/invoice.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  https://api.pdfcrowd.com/convert/24.04/

Customize text extraction

These examples upload extraction.pdf, a three-page document with a two-column article, wrapped paragraphs, and invoice fields.

Extract selected pages

Extract pages 1 and 3 of extraction.pdf into excerpt.txt.

curl -f -s -S \
  -u 'demo:demo' \
  -o excerpt.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  -F print_page_range=1,3 \
  https://api.pdfcrowd.com/convert/24.04/

Extract text without layout spacing

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.

curl -f -s -S \
  -u 'demo:demo' \
  -o article.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  -F no_layout=true \
  -F print_page_range=1 \
  https://api.pdfcrowd.com/convert/24.04/

Reconstruct wrapped paragraphs

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.

curl -f -s -S \
  -u 'demo:demo' \
  -o paragraphs.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  -F paragraph_mode=bounding-box \
  -F print_page_range=2 \
  -F remove_hyphenation=true \
  https://api.pdfcrowd.com/convert/24.04/

Extract text from a page region

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.

Exclude headers and footers:

curl -f -s -S \
  -u 'demo:demo' \
  -o body.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  -F crop_area_height=648 \
  -F crop_area_width=540 \
  -F crop_area_x=36 \
  -F crop_area_y=72 \
  https://api.pdfcrowd.com/convert/24.04/

Extract an invoice field block:

curl -f -s -S \
  -u 'demo:demo' \
  -o fields.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  -F crop_area_height=70 \
  -F crop_area_width=300 \
  -F crop_area_x=36 \
  -F crop_area_y=290 \
  -F print_page_range=3 \
  https://api.pdfcrowd.com/convert/24.04/

Keep page boundaries

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.

Use form-feed separators:

curl -f -s -S \
  -u 'demo:demo' \
  -o pages.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  -F page_break_mode=default \
  https://api.pdfcrowd.com/convert/24.04/

Use visible separators:

curl -f -s -S \
  -u 'demo:demo' \
  -o separated.txt \
  -F file=@extraction.pdf \
  -F input_format=pdf \
  -F output_format=txt \
  --form-string 'custom_page_break=
--- PAGE BREAK ---
' \
  -F page_break_mode=custom \
  https://api.pdfcrowd.com/convert/24.04/