tr Skip to content
Black Friday FlowMattic for life, 12 payments of $33.25 Or $399 once. Nothing added for splitting Ends in --Days --Hrs --Min --Sec See the deal

Extract Text from PDF Files Automatically with PDF Parser

FlowMattic PDF Parser module: an invoice PDF from an email attachment is read into text, and a search finds invoice number INV-2041 on page 1.

FlowMattic’s PDF Parser lets a workflow extract text from PDF files, page by page, without a separate document service. Point it at a PDF URL or a Media Library ID and it returns the full text, a per-page breakdown and the document metadata. It can also search for a phrase or pattern with page numbers, and pull embedded images into the Media Library.

When you need to extract text from PDF documents as part of a process, this is the step. It suits invoice routing, contract checks, résumé screening and any process where documents arrive as PDFs and the next step needs their contents. This guide covers the four actions, every field, what comes back, and how the module handles scanned and protected files.

What is the PDF Parser?

PDF Parser by FlowMattic is a built-in action module, added in FlowMattic 7.2.0, that reads “text, metadata and images out of a PDF file in your workflow”. It reads the file on your own WordPress server with a bundled PDF library, next to the other data tools.

  • Parse PDF: extract the text, with an optional per-page breakdown, page range and metadata.
  • Get PDF Metadata: read the title, author, subject, keywords, producer, dates and page count without extracting text.
  • Search PDF Text: find a word, phrase or regular expression and return each match with its page number and surrounding text.
  • Extract Images from PDF: save embedded images to the Media Library.

How to extract text from PDF files in a workflow

  1. Add a trigger that gives you a PDF, such as an email with an attachment, a webhook with a file URL, or a PDF your workflow just generated.
  2. Add a step, choose PDF Parser by FlowMattic and pick Parse PDF.
  3. Map the file into PDF File URL or Media ID. A plain number is read as a Media Library attachment ID; anything else must be a URL starting with http:// or https://.
  4. Optionally set Page Range, such as 1-3,7, and Include Per-Page Text.
  5. Test the step and map text, or any page’s text, into the next step.
FlowMattic workflow builder showing the PDF Parser by FlowMattic step with the Parse PDF action and its PDF File URL or Media ID, Page Range and Include Per-Page Text fields.
A PDF Parser step set to Parse PDF, with a PDF address, a page range and the per-page text option.

A successful Parse PDF returns fields like these:

{
  "status": "success",
  "status_code": "parsed",
  "has_text_layer": true,
  "likely_scanned": false,
  "text": "Invoice INV-2041 ... Total due: 1,249.50",
  "character_count": 1834,
  "word_count": 297,
  "page_count": 2,
  "pages_parsed": 2,
  "metadata": { "title": "...", "author": "...", "created_date": "...", ... },
  "pages": [ { "page": 1, "text": "...", "character_count": 1210, "word_count": 196 }, ... ],
  "source": { "type": "media", "attachment_id": 512, "filename": "inv-2041.pdf", ... }
}

When the URL points at a file in this site’s own Media Library, the module reads it from disk instead of downloading it. Other URLs are downloaded with a 30-second timeout and up to five redirects, and the file must really be a PDF, or the step says so.

Fields for each action

ActionFieldsKey output
Parse PDFPDF File URL or Media ID, Page Range, Include Per-Page Text (Yes or No)text, pages, metadata, word_count, likely_scanned
Get PDF MetadataPDF File URL or Media IDpage_count, metadata
Search PDF TextPDF File URL or Media ID, Search For, Match Type (Contains Text or Regular Expression), Case Sensitive, Context Characters, Page Rangefound, match_count, pages_matched, first_page, first_match, matches
Extract Images from PDFPDF File URL or Media ID, Page Range, Minimum Width, Minimum Height, Maximum Imagesimage_urls, first_image, images, skipped, images_saved

Search PDF Text

Each match comes back with its page, the matched text, its position on the page and an excerpt of the text around it. Context Characters sets how much surrounding text you get, 120 by default and up to 2,000. With Regular Expression, enter a bare pattern such as INV-[0-9]{4} or a delimited one. The status_code is found or not_found, which is easy to route on.

FlowMattic PDF Parser step with the Search PDF Text action, showing Search For set to INV-[0-9]{4}, Match Type set to Regular Expression, and the Case Sensitive and Context Characters fields.
Search PDF Text looking for an invoice number with a regular expression.

Extract Images from PDF

Images are saved to the Media Library and named after the PDF, page and position, such as inv-2041-p1-1.jpg. JPEGs are kept as stored; RGB, grayscale and palette images are rebuilt as PNG. CMYK, JPEG 2000 and fax-encoded (CCITT or JBIG2) images can’t be converted and are listed under skipped with the reason. Maximum Images defaults to 25 and goes up to 200.

Use cases

Route supplier invoices by number

Invoices arrive as email attachments. Import them to the Media Library, search for the invoice number pattern, and route each one to the right approver or record.

Flow: Email with Attachment → Import Email Attachments to Media Library → Search PDF Text → Router

Summarise a contract with an AI agent

Parse the contract with Include Per-Page Text set to No, then ask an AI agent for the term, renewal date and notice period, and email the summary to the account owner.

Flow: Webhook (Capture Webhook Response) → Parse PDF → AI Agent → Send Email

Flag auto-renewal clauses

A legal or operations team can search every incoming agreement for “automatically renew” and send only the matches, with page numbers and excerpts, for review.

Flow: Email with Attachment → Import Email Attachments to Media Library → Search PDF Text → Filter → Send Email

Screen résumés for a hiring pipeline

An agency recruiting for clients parses each CV, has an AI agent score it against the role, and stores the result in a table the recruiters review.

Flow: Email with Attachment → Import Email Attachments to Media Library → Parse PDF → AI Agent → WP Tables (New Record)

Read scanned receipts with an AI vision step

A scanned receipt has no text to read, but the scan itself is an image. Extract it and send first_image to an image-reading AI action, such as Claude’s Analyze Image with Vision.

Flow: Email with Attachment → Import Email Attachments to Media Library → Extract Images from PDF → Claude (Analyze Image with Vision) → WP Tables (New Record)

Check generated invoices before they go out

After a store generates an invoice PDF, search it for the order total. A Filter sends the email only when the expected figure is on the page.

Flow: WooCommerce new order → PDF Builder (Generate PDF from Template) → Search PDF Text → Filter → Send Email

Tips and gotchas

  • There is no OCR. Only text stored as text can be read. On a scan, Parse PDF and Search PDF Text return status error with status_code scanned_pdf and a message pointing you to Extract Images from PDF.
  • Watch likely_scanned. A document with only a stray line of text per page parses, but likely_scanned is true, so you can branch before trusting the text.
  • Metadata works on scans. Get PDF Metadata reads the document information only, so it succeeds on scanned files too.
  • Password-protected files aren’t supported. The step returns a clear error; remove the protection first.
  • Page ranges are forgiving. 1-3,7 reads pages 1, 2, 3 and 7, and pages beyond the end are ignored. Only a range that matches no page at all is an error.
  • Keep responses small. Set Include Per-Page Text to No when you only need the full text of a long document.
  • Search results are capped. A search returns up to 500 matches, while match_count still reports the total.
  • Drop logos and icons. Set Minimum Width and Minimum Height so small graphics are skipped. Images beyond Maximum Images are listed under skipped, so nothing disappears silently.
  • Errors fail the run. A status of error marks the run as failed in Task History. Switch on Ignore Errors in the step’s settings if you want to branch on status_code instead.

Related features

FAQ

How do I extract text from a PDF in WordPress?

Add a PDF Parser step with Parse PDF and give it the PDF’s URL or its Media Library ID. The step returns the full text in text and, if you keep Include Per-Page Text on, each page separately in pages.

Can FlowMattic read scanned PDFs?

Not as text, because the module has no OCR. It detects scans and reports them instead of returning empty text. Extract Images from PDF still works on scans, so you can pass the page images to an AI action that reads images.

Can I search a PDF for an invoice number?

Yes. Use Search PDF Text with Match Type set to Regular Expression and a pattern such as INV-[0-9]{4}. The first hit is in first_match, with its page number and an excerpt.

Does it work with PDFs attached to emails?

Yes. Import the attachment to the Media Library with the IMAP Email Parser first, then pass its URL or attachment ID to the PDF Parser. Files in the Media Library are read straight from disk.

The PDF Parser ships with FlowMattic and reads every document on your own server. See the plans and extract text from PDF files inside your own workflows.

More from the blog