vøiddo guidesAll Actors on Apify

PDF text extractor: how to get text and metadata from PDF files as Markdown or JSON (API, Python, no code)

Extract the text of PDF files page by page, as plain text or as Markdown with headings, bold, lists and paragraphs, ready for LLM and search pipelines. This guide shows the output fields, a working input, and Python, JavaScript and cURL code for the Actor v0iddo/pdf-text-extractor on Apify.

Open PDF text extractor on Apify

What data you get

One row per result. Every row can be downloaded as JSON, CSV, Excel or HTML, or read through the API.

FieldLabelTypeExample
index#number0
page_countPagesnumber6
charsCharactersnumber37817
pagesText by pagelist[{"n": 1, "markdown": "Form W-9 (Rev. March 2024)\n\n# Request for ...
metadataMetadataobject{"title": "Form W-9 (Rev. March 2024)", "subject": "Request for Tax...
creditsnumber1
msnumber404

Input example

This is the input that is pre-filled on the Actor page. Change the values for your own run.

{
  "file_urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "format": "markdown"
}
Input fieldTypeWhat it does
file_urlstringPublic http(s) URL of the file.
file_urlsarrayMany files in one run: one public http(s) URL per line, up to 1000.
file_textstringThe file content pasted as text.
file_base64stringThe file content as base64 (or a data: URI).
pagesstringPages to extract, e.g. '1-3,7' or '5-' (default: all pages).
layoutbooleanPreserve the visual layout (columns, spacing) instead of reading order.
formatstringtext: the plain text of each page.
itemsarrayOptional. A list of input objects with the same fields as above; every object is processed in its own right and the top-level fields act as shared defaults.

Output sample

Real rows from a run of the Actor. Fields that name people are left out of the sample.

[
  {
    "index": 0,
    "page_count": 6,
    "pages": [
      {
        "n": 1,
        "markdown": "Form W-9 (Rev. March 2024)\n\n# Request for Taxpayer Identification Number and Certification\n\nDepartment of the Treasury Internal Revenue S..."
      },
      {
        "n": 2,
        "markdown": "must obtain your correct taxpayer identification number (TIN), which may be your social security number (SSN), individual taxpayer identi..."
      },
      {
        "n": 3,
        "markdown": "Certain payees and payments are exempt from backup withholding. See Exempt payee code, later, and the separate Instructions for the Reque..."
      }
    ],
    "chars": 37817,
    "metadata": {
      "title": "Form W-9 (Rev. March 2024)",
      "subject": "Request for Taxpayer Identification Number and Certification",
      "keywords": "Fillable",
      "producer": "Designer 6.5",
      "created": "2024-03-06T13:18:13Z",
      "modified": "2024-03-06T13:18:13Z"
    },
    "credits": 1,
    "ms": 404
  }
]

Code: Python, JavaScript and cURL

Get your API token in Apify Console under Settings, then Integrations. The Actor id is v0iddo/pdf-text-extractor.

Python (apify-client)

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run_input = {'file_urls': ['https://www.irs.gov/pub/irs-pdf/fw9.pdf'], 'format': 'markdown'}

run = client.actor("v0iddo/pdf-text-extractor").call(run_input=run_input)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

JavaScript (apify-client)

import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });

const input = {
  "file_urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "format": "markdown"
};

const run = await client.actor('v0iddo/pdf-text-extractor').call(input);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);

cURL

curl -X POST "https://api.apify.com/v2/acts/v0iddo~pdf-text-extractor/run-sync-get-dataset-items" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"file_urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"], "format": "markdown"}'

Price

$1.00 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $0.70 per 1,000. See the pricing tab for your plan. A new Apify account gets $5 of platform credit every month.

FAQ

What data does the PDF text extractor return?

Each result is one row in an Apify dataset. Fields include index, page_count, chars, pages, metadata, credits, ms. The table above shows every field with an example value.

How do I use the PDF text extractor from Python?

Install the apify-client package, create a client with your Apify API token, call the Actor v0iddo/pdf-text-extractor with an input like the one above, and read the rows from the run's dataset. The Python snippet above does exactly that.

Can I use it without writing code?

Yes. Open the Actor page on Apify, fill in the input form (an example is already filled in), press Start, and download the results as JSON, CSV, Excel or HTML. You can also schedule runs there.

How much does it cost?

$1.00 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $0.70 per 1,000. A new Apify account gets $5 of platform credit every month.

How do I limit the number of results?

Set a maximum cost for a run in the run options on Apify, and the run stops when it is reached.

Can I send the results to Google Sheets, Make, Zapier or n8n?

Yes. Apify datasets connect to Google Sheets, Slack, Make, Zapier and n8n, and a webhook can call your own service when a run finishes. You can also export the dataset as JSON, CSV or Excel.

Open PDF text extractor on Apify

Related guides