PDF → one file per match

Split PDF by Text

Cut a combined PDF, such as a batch of scanned invoices or a stack of statements, at every page whose text contains a word or matches a pattern. Name each piece from the text that was found, check the page ranges, then save a ZIP.

PDF

The text layer is read page by page, up to 2000 pages and 50 MB.

Drop your PDF here or click to choose

.pdf

Where to cut

A page matches when its text

File names

Tags: {stem} source name, {capture} captured text, {n} number, {first} and {last} page.

With a plain word, {capture} is the rest of the line after it, up to 80 characters, with a leading colon or number sign removed.

Preview

Choose a PDF to see the ranges.

Split PDF by Text

Operator: Abdulla Al Fahad. How tools are built and checked

A payroll run or a statement batch arrives as one PDF holding twenty payslips, or a month of statements for forty customers, and every one of them has to become its own file. When each document opens with the same words, such as "Payslip for" or "Statement of Account", those words are a better place to cut than a guessed page count.

This tool reads the text of every page, marks the pages that contain a phrase or match a regular expression, and turns the marks into page ranges. Unlike Split PDF here, which cuts at fixed counts or ranges you type, the cut follows the content, so an invoice that runs to three pages and the next that runs to one both come out whole.

Key features

  • Phrase or regular-expression matching, with an exact-case option
  • Cut before or after the matching page, with three ways to treat pages outside every match
  • File names built from the matched text, a regex capture group or the rest of the phrase's line
  • A live preview of every range with its matched page and captured text, and a plan CSV
  • A single piece downloads as a PDF, several as one ZIP, up to 1,000 pieces

How matching pages become files

A page matches when its extracted text contains the phrase, ignoring case unless you tick exact matching, or when the pattern finds a match anywhere on it. Patterns run with the multiline flag, so ^ and $ match at line breaks. Only the first match on a page counts. The text of a page is built line by line: a line break goes where the baseline changes, and a space goes between two pieces of text that have a visible gap, so "Invoice No:" and "1042" stored as separate pieces still read as one line.

The cut position decides what a match means. With "starts a new file" the matching page is the first page of its piece; with "ends the file it is in" it is the last, which suits documents that finish on a page saying "Total due" or "End of statement". Pages outside every match, those before the first match or after the last one, can become their own file, be joined to the nearest piece, or be left out. File names come from a template with five tags: {stem} for the source name, {capture} for the matched text, {n} for the number, and {first} and {last} for page numbers. In regex mode {capture} is the chosen group (0 is the whole match); with a plain phrase it is the rest of the line after the phrase, minus a leading colon, number sign, full stop or dash, cut to 80 characters. Names are made safe for Windows and macOS: < > : " / \ | ? * and control characters become spaces, names are cut to 100 characters, reserved names such as CON get an underscore, and repeated names get " (2)", " (3)". Pieces with no capture are called part-<n>, front-pages or end-pages.

How it works

The PDF is opened with pdf.js and the text of each page is read once, up to 2,000 pages and 50 MB, with a cancel button. Changing the pattern, the cut position or the template afterwards re-runs only the matching and naming, not the reading, so the preview updates as you type.

Writing uses pdf-lib. Each range is copied into a new document by the same page-copy routine Split PDF uses, so the pages arrive unchanged and the source title is kept. Bookmarks and form fields stay behind, and the tool says so when the file has form fields.

Common use cases

  • A 300-page scanned ledger where every account section opens with "Account: 4100 Sales": a regex of Account:\s*(\d+) with the template {capture}-{n} gives 4100-01.pdf, 4100-02.pdf and so on.
  • A bank's year-end file with one statement per customer, each ending on a page that says "End of statement": cut after the match, leave out the pages after the last one, and the legal notice at the back is dropped.
  • A 40-page PDF of 20 payslips that each open "Payslip for Ana Ruiz": cutting before each match with the template {capture} produces Ana Ruiz.pdf, and the next employee's file after it.

How to use this tool

  1. Drop the PDF and wait for the page count; pages with no text layer are counted for you.
  2. Choose a phrase or a regular expression and type it, then pick whether a matching page starts or ends a file.
  3. Decide what happens to pages outside every match and set the name template.
  4. Check the preview table, then save the ZIP, or the PDF when only one piece results.

Example

A 6-page scan named march-scans.pdf

Page 1: cover sheet
Page 2: Invoice No: INV-1001 (continues on page 3)
Page 4: Invoice No: INV-1002
Page 5: Invoice No. INV-1003 (continues on page 6)
Phrase: Invoice No, a match starts a new file, template {stem}-{capture}

Files in the ZIP

march-scans-front-pages.pdf (page 1)
march-scans-INV-1001.pdf (pages 2-3)
march-scans-INV-1002.pdf (page 4)
march-scans-INV-1003.pdf (pages 5-6)
Joining the leading pages to the nearest piece instead gives INV-1001 as pages 1-3 and no front-pages file.

Common pitfalls

Only pages with a text layer can match. A scanned page with no recognised text never does, and the tool counts those pages; run Make PDF Searchable (OCR) first.

A page that matches twice counts once. If an invoice's second page repeats "Invoice No" in a footer, that page also matches and opens another file, so choose a phrase found only on first pages or anchor the pattern with ^.

A pattern with nested repetition such as (a+)+ can make the tab stall on a long page. Page text is capped at 200,000 characters, but the match itself cannot be interrupted.

  • The Captured column of the preview shows exactly what {capture} will hold, trimmed to 80 characters, so test a regular expression there before saving anything.
  • A label that the PDF splits across lines, with "Invoice" above "No.", will not match a one-line phrase, but a regex with \s+ between the words matches across the line break.

Common errors and how to fix them

No page matches
Copy the phrase out of a PDF viewer into the box rather than typing it: a non-breaking space or a joined "fi" ligature in the PDF will not match the plain characters you type. A shorter fragment is more forgiving.
The pattern has 0 capture groups, so group 1 does not exist
Wrap the part you want in parentheses, for example Invoice No:\s*(\w+), or set the group to 0 to use the whole match.

Choosing between a phrase and a regular expression

Most batches need only a phrase. A regular expression earns its place when the identifier sits between other text or has a fixed shape that a phrase cannot express.

  • A phrase is the quickest to set up, and {capture} becomes the rest of its line.
  • A regular expression with one group, such as Case No\.\s*(\S+), names files from just that group.
  • A regular expression with group 0 uses the whole match, which suits a pattern like INV-\d{4} that is itself the name.

Frequently asked questions

Can it cut where the text changes instead of where a phrase appears?

No. It cuts only at pages that match the one pattern. For fixed counts use Split PDF here, and for customer changes pick a pattern that every first page of a customer shares.