Schema LawSign in with Google

Extract Pages Containing a Word From a PDF Into a New File

By Schema LawPublished Updated

To extract pages containing a word from a PDF, search the file for the word, write down the page of every hit, then extract those pages into a new PDF. The search builds the list and the page tool does the pulling. Both steps depend on the file having a text layer on every page.

Can you extract every page that contains a word from a PDF?

Yes, in two steps: a search that lists the pages where the word appears, and an extraction of those pages into a new file. Whether your editor joins the two into one command is for its own documentation to say; done by hand, the job needs only a search panel and a page organizer.

The result is only as complete as the text behind the pages. A search reads the text layer, not the picture, so a page that was never recognized, or one where the word was misread, will not be on your list. Before you trust the list for a 600-page records file, run the page-by-page test in the guide to checking whether a PDF is searchable on every page. If the file turns out to be image-only, add the text first. Schema Law reads an uploaded PDF, PNG or JPEG into text and exports a searchable PDF among its export formats.

Choose the searches from the job itself. Look up the party names, an exhibit number, and a Bates number you can see, and write down every page the panel returns. Open three hits and set them beside the page image before you pull anything out. A deposition page that shows the name in the picture and not in the list has to be added by hand.

Decide one thing before you start: what the new file is for. A working set for your own review can be generous and include near misses. A set you will hand to an expert or attach to a declaration needs a list you can explain page by page.

Listing the hit pages for a word before you extract anything

Build the list from a search panel that shows every hit at once, not from pressing Enter through the file. You want one line per hit with its page, so you can count, sort and remove duplicates before any page moves.

Adobe documents such a panel in its guide to searching PDFs in Acrobat. After a search from the Search window, it says, "the results appear in page order, nested under the names of each searched document", and each item "includes a few words of context". The same page says you can save the results as a PDF or a CSV file. Other readers have their own results panels; check what yours can export.

Turn the hits into a page list this way.

  1. Search for the word with whole-word matching off first, so that "Hartwell" also catches "Hartwell's" and "HARTWELL".
  2. Save or copy the results into a spreadsheet, one row per hit.
  3. Reduce the rows to one per page. Six hits on one page are still one page to extract.
  4. Search again for each variant you expect: a hyphenated form, an abbreviation, a likely misreading. Add any new pages.
  5. Sort the pages and write them as ranges: 14, 37-39, 112, 240-241.
  6. Open three pages from the list and three that are not on it, and confirm the list is behaving as you expect.

Which options to set for the search itself is covered in the section on exact match, case, whole words and phrases in PDF search. A person's or a company's name needs more variants than an ordinary word; the post on searching a scanned PDF for a name shows how to build that list.

Extracting the hit pages into a new PDF that stays searchable

Extract the listed pages with the editor's page-extraction command, and leave the source file untouched. Extraction copies the pages as they are, text layer included, into a new document.

Adobe's instructions for extracting pages from a PDF in Acrobat say that "The extracted pages include all content, form fields, comments, and links from the original." The dialog it describes has two checkboxes, "Delete pages after extracting" and "Extract pages as separate files", and Adobe says to leave both unchecked "to keep the original intact and create a new PDF." It also notes that bookmarks and article threads tied to the pages are not extracted.

A routine that works in any editor with an extract command:

  1. Work on a copy of the source, never the only one.
  2. Select the pages from your list. If the editor takes a typed page list, paste the ranges; if it takes thumbnails, select them in order.
  3. Extract to one new file, with the option to delete pages from the source switched off.
  4. Save under a name that states the source and the term, such as Dunmore-records_pages-mentioning-Hartwell.pdf.
  5. Count the pages in the new file against the count on your list.
  6. Search the new file for the word. Every page should produce a hit. A page that does not was added by mistake, or its text did not come across.

Avoid making the new file by printing selected pages to a PDF printer. The section on extracting pages versus printing a page range to a new PDF explains which method keeps the text.

Which neighbouring pages belong with a page that mentions the word?

Add the pages a reader needs in order to understand the hit: the start of the document the page belongs to, and any page the passage runs onto. A page lifted alone can lose its date, its author and the end of its sentence.

Use the hit as a pointer to a document, then decide how much of that document to take.

The hit is onPages to consider adding
A page in the middle of a letter or reportThe first page (date, parties) and the signature page
A transcript pageThe page before and after, plus the page naming the witness
A row of a table that runs over several pagesThe page carrying the column headings
An attachment to an emailThe email it came with
A page that ends or begins mid-sentenceThe adjoining page

Mark in your spreadsheet which pages are hits and which were added for context, with a column for each. When someone later asks why page 36 is in the set and does not contain the word, the answer is already written down.

Keep the extracted pages in source order. Reordering by importance makes the set harder to check against the original, and gives a reviewer no quick way to confirm that nothing is missing.

Recording where each extracted page sat in the source PDF

Record the source page of every extracted page at the moment you extract, because the new file renumbers everything from one. Page 240 of the source becomes page 9 of the extract, and nothing in the new file says so.

A short index kept beside the extract is enough.

Page in extractPage in source filePrinted number or Bates numberHit or context
114DUN-000014Hit
236DUN-000036Context
337DUN-000037Hit

Add a line at the top with the source file's name, its total page count, the search term and the date of the search. Save the index as the first page of the extract or as a separate file with a matching name.

Before you cite a page, check whether your court's rules or an agreement with the receiving party say which file a reference must point to. The index lets you turn a page of the extract back into a page of the source either way. If the position of a page in the source file differs from the number printed on it, the post on why PDF page numbers do not match the printed page explains the three kinds of number and how to keep them apart.

All posts in Searchable PDFs