Skip to main content

Pull Pages 1 and 2 Out of a Four-Page Contract in Power Automate: A Five-Step Dropbox Flow

8 min read
PDF4me Team

Extract Pages is a PDF4me action for Power Automate that pulls a chosen set of pages out of a PDF into a new document. This walkthrough builds a five step flow that reads a four page contract from /pdf4metest/extract/4page.pdf, takes pages 1,2 with PDF - Extract Pages, shrinks what comes back with PDF - Compress, and writes Pages 1-2 - 4Page.pdf to an output folder. Swap the path for your own and keep the wiring.

The short version

1. Manually trigger a flow → 2. Dropbox, Get file content using path with Infer Content Type on Yes → 3. PDF - Extract Pages: File Name 4Page.pdf, Page Numbers 1,2 → 4. PDF - Compress with Optimize Profile Max → 5. Dropbox, Create file named Pages 1-2 - 4Page.pdf.

Page Numbers has to stay inside the document

Asking for page 7 of a four page file is the usual reason Extract Pages hands back an empty or broken PDF. Check the value in Page Numbers against the real page count before you run the flow over a folder.

What you are automating​

The request is always some version of the same thing. Legal needs the signature page, the auditor needs pages 4 to 9, somebody needs the summary without the forty pages of appendix behind it. By hand that means opening the contract, finding the pages, exporting a selection, and emailing a file that is somehow still eleven megabytes. Here it is two PDF4me actions, with 1,2 in one field and Max in the other.

At a glance​

  1. Manually trigger a flow
  2. Get file content using path (Dropbox)
  3. Extract Pages (PDF4me)
  4. Compress (PDF4me)
  5. Create file (Dropbox)
The completed Power Automate run extracting and compressing pages, every step ticked green
The run this post was written from: five steps, all green.

The whole run took about 13 seconds. Compression accounted for 11 of them.

Why this pattern works​

Few fields to fill

Extract Pages needs three things: File Content, File Name and Page Numbers. Compress takes the extracted document and an Optimize Profile.

Page Numbers takes an expression

The field accepts a dynamic expression, so the page can be worked out earlier in the flow instead of being typed in as 1,2: find the page carrying a particular phrase, or take the last page of whatever arrived.

Extracted pages carry their weight

Pull two pages out of a scanned contract and you get two pages of scan, at whatever resolution the scanner used. The page count drops; the file size often does not.

Before you start​

Checklist
  • The PDF4me PDF connector in your Power Automate environment.
  • A storage connection. This flow uses Dropbox.
  • A multi page PDF. Ours is a four page contract at /pdf4metest/extract/4page.pdf.

Build the flow​

Step 1: Manually trigger a flow​

The flow starts on Manually trigger a flow.

Step 2: Get file content using path (Dropbox)​

Flow so far: trigger.

  1. Add Dropbox: Get file content using path.
  2. Point it at the four page contract, ours at /pdf4metest/extract/4page.pdf.
  3. Infer Content Type: Yes.
The Dropbox Get file content using path step reading the four page contract

Step 3: Extract Pages (PDF4me)​

Flow so far: trigger, Get file content using path.

PDF - Extract Pages needs three things, and it is the simplest action in this whole flow.

FieldValue hereWhy
File Contentfrom the Dropbox step
File Name4Page.pdf
Page Numbers1,2a comma separated list, so this is the first two pages
The PDF4me Extract Pages step with File Name 4Page.pdf and Page Numbers set to 1,2
Step 3: three fields, one of which decides what you get.

Ranges work in the same field, which is how you ask for pages 4 through 9 without typing six numbers.

The field also takes a dynamic expression, which is where this gets interesting. A fixed 1,2 only helps when the pages you want are always in the same place. If they are not, work out the page number earlier in the flow and feed it in: find the page carrying a particular phrase, or take the last page of whatever arrived.

Step 4: Compress (PDF4me)​

Flow so far: trigger, Get file content, Extract Pages.

  1. Add PDF - Compress. It takes the extracted document and an Optimize Profile.
  2. Optimize Profile: Max.
The PDF4me Compress step with Optimize Profile set to Max
Step 4: Optimize Profile on Max.

We used Max, which is the right default for something being emailed. If the pages are going to a printer or into an archive, a gentler profile preserves more. This step took 11 of the flow's 13 seconds, which is worth knowing before you run it across a few hundred contracts.

Step 5: Create file (Dropbox)​

Flow so far: trigger, Get file content, Extract Pages, Compress.

  1. Add Dropbox: Create file.
  2. Point it at your output folder.
  3. Name the file Pages 1-2 - 4Page.pdf.
  4. File Content: from the Compress step.
The Dropbox Create file step writing Pages 1-2 - 4Page.pdf
Step 5: the name says which pages are inside.

Name the output so it says what it contains. A name carrying the page range tells the next person what they are looking at without opening it. A folder of extract.pdf, extract (1).pdf and extract (2).pdf helps nobody.

Quick reference​

#ActionMain mapping
1Manually trigger a flow—
2Get file content using path/pdf4metest/extract/4page.pdf, Infer Content Type Yes
3Extract PagesFile Name 4Page.pdf, Page Numbers 1,2
4Compressthe extracted document, Optimize Profile Max
5Create filePages 1-2 - 4Page.pdf, File Content from Compress

Troubleshooting​

The extraction returns an empty or broken PDF

Check that Page Numbers sits inside the document's actual page count. Asking for page 7 of a four page file is the usual cause.

The output is still too big to email

Try a stronger Optimize Profile, then check whether the source is a scan. A scanned page compresses far less than a text page.

The step rejects the file

Check Infer Content Type on the Dropbox Get file content using path step.

What to try next​

FAQ​

How do I extract pages from a PDF in Power Automate?​

Add the PDF4me Extract Pages action, map File Content from your storage step, and put the pages you want in Page Numbers as a comma separated list such as 1,2.

Can I extract a range of pages?​

Yes. Page Numbers accepts ranges as well as individual numbers, so you can ask for pages 4 through 9 without listing each one.

Can the page numbers be dynamic?​

Yes, and this is where the flow stops being a shortcut and starts being useful. Work the page number out earlier in the flow and pass it in, rather than hard coding it.

Why is my extracted file still large?​

Extracted pages keep the resolution of the original. Add a Compress step after the extraction, as this flow does.

Sending somebody forty pages when they asked for two is its own small rudeness. Change the path, put your own pages in Page Numbers, and pick an Optimize Profile that suits where the file is going.