Skip to main content

Convert PDF to Text File in Power Automate: Turn Scanned Contracts into a Searchable SharePoint Corpus with PDF4me

· 25 min read
SEO and Content Writer

PDF4me Extract Text and Images is a Power Automate action that returns the text layer of a PDF as an array. Paired with OCR upstream and a Compose join downstream, this flow turns every PDF dropped in a SharePoint library into a matching .txt file, ready for AI search.

Search for how to do this and the first result is Microsoft's own PDF actions reference, which describes Power Automate Desktop actions. They do not exist in a cloud flow. That single detail is why the next two results are a Reddit thread and a Power Platform community thread of people asking the same question and not getting a straight answer. This flow is the straight answer, and it runs entirely in the cloud on standard-tier connectors.

The flow at a glance
1. When a file is created (properties only)
SharePoint trigger on the library, scoped to the RagInput folder. Returns metadata, not bytes.
2. Get file content
Fetches the actual PDF bytes using the identifier the trigger handed over.
3. Convert PDF to editable PDF using OCR
Adds a text layer to scans. OCR Only When Needed skips PDFs that already have one.
4. Extract Text and Images
Returns the text as an array. Extract Images stays No.
5. Compose
join() flattens the texts array into one newline separated string.
6. Create file
SharePoint writes the string to /Shared Documents/RagText as .txt.
The short version

A PDF lands in a SharePoint library. The trigger reports the new item, Get file content fetches its bytes, and PDF4me runs OCR only if the file needs it before pulling the text out as an array. A one line Compose expression joins that array into a single string, and SharePoint writes the result next door as a plain text file. Six actions, no premium connector, and the whole run finishes in about twelve seconds.

Why-Based Q&A

Why write a .txt file instead of just using the text in the flow? A string inside a flow run lives for the length of that run. A file in a library is durable, indexable, and readable by anything you point at it later, whether that is SharePoint search, a vector database, or a chatbot pulling context.

Why does it take two actions to get one file? The properties-only trigger is deliberately lightweight. It reports that an item appeared and hands you its metadata, including an identifier, but no bytes. Get file content exchanges that identifier for the document itself. Splitting the two keeps the trigger fast and lets you filter on metadata before you ever download anything.

Why run OCR when most PDFs already have text? Because you cannot tell by looking. A scanned contract and a born-digital one are indistinguishable in a folder listing. The OCR action's OCR Only When Needed setting inspects each file and skips the ones that already carry a text layer, so you pay the cost only where it buys something.

Why is a Compose step needed at all? Extract Text and Images returns texts as an array, usually one entry per page. Writing an array straight to a file gives you JSON brackets and escaped quotes. Compose joins the entries into clean prose before anything touches disk.


What You'll Get

Input: any PDF dropped into a SharePoint document library, scanned or born-digital, no naming convention required. Output: one plain text file per PDF in a second library, containing the full readable contents of the document.

SharePoint Documents library showing the RagInput folder containing rag-test.pdf, rag-test2.pdf and services-agreement.pdf, all modified by the Pdf4me Flow account

RagInput. Drop a PDF here and the flow starts.

SharePoint Documents library showing the RagText folder containing rag-test.pdf.txt and rag-test2.pdf.txt produced by the flow

RagText. One plain text file per PDF, ready to index.

Here is what comes out the other side for the sample contract, exactly as written to disk:

MASTER SERVICES AGREEMENT
Between Initech LLC and Umbrella Inc.
Effective date: 1 January 2026. Auto-renews annually.
Liability cap: USD 100000. Confidentiality: 5 years.
CLEAN TEST MARKER: PDF4ME-CLEAN-TEST-2026.

Note the leading spaces. OCR preserves layout whitespace, and that is fine for search and for feeding a language model. Trim it later if a downstream parser is fussy.


What You Need

  • Power Automate. Open Power Automate. This is a cloud flow. Everything here is standard tier, no premium connector and no gateway.
  • PDF4me API key. Get your API key. Connect it the first time you add a PDF4me action.
  • A SharePoint site with two folders. One for input PDFs and one for output text. Create both before you build, so the folder pickers have somewhere to point.
  • A test PDF. contract-sample.pdf. A short services agreement with a marker line you can grep for.

Grab the samples first. Upload the PDF to your input folder once the flow is saved, then compare what lands in the output folder against the expected text file.


The Flow at a Glance

  1. When a file is created (properties only) (SharePoint trigger) scoped to /Shared Documents/RagInput.
  2. Get file content using the trigger's Identifier.
  3. PDF - Convert PDF to editable PDF using OCR with quality Draft and OCR Only When Needed true.
  4. PDF - Extract Text and Images with Extract Text Yes and Extract Images No.
  5. Compose running a join() over the returned texts array.
  6. Create file (SharePoint) writing .txt into /Shared Documents/RagText.

Complete flow overview

Power Automate run history showing six actions succeeding in order: SharePoint When a file is created properties only at 0.3 seconds, Get file content at 0.2 seconds, PDF Convert PDF to editable PDF using OCR at 11 seconds, PDF Extract Text and Images at 0.4 seconds, Compose at 0 seconds, and SharePoint Create file at 0.3 seconds

OCR is the only slow step at 11 seconds. The other five finish in under half a second each.


Step 1: How do you watch a SharePoint library for new PDFs?

Flow so far: nothing yet, this is the trigger.

Use When a file is created (properties only). It fires on new items and returns their metadata. Scope it to one folder, because a library-wide watch fires on every upload anyone makes anywhere in that library.

  1. Create an Automated cloud flow and pick When a file is created (properties only).
  2. Configure:
    • Site Address: https://ynoox1.sharepoint.com/sites/PDF4meSharepoints
    • Library Name: pick Documents from the dropdown
  3. Open Advanced parameters, add Folder, and set it to /Shared Documents/RagInput.

SharePoint trigger configuration

Power Automate When a file is created properties only trigger panel with Site Address set to PDF4me Sharepoints, Library Name set to Documents, and the advanced Folder parameter set to /Shared Documents/RagInput

Library Name is the library itself, Documents. The Folder parameter underneath is what narrows the trigger to one folder inside it.

Tip. You will also find a trigger called When a file is created in a folder, which returns the file bytes directly and saves you the next action. It is marked deprecated, so prefer the properties-only pairing shown here for anything you intend to keep running.


Step 2: Why do you need Get file content after the trigger?

Flow so far: SharePoint trigger.

The properties-only trigger hands over metadata, not the document. Get file content exchanges the trigger's Identifier for the actual bytes that PDF4me needs.

  1. Add SharePoint > Get file content.
  2. Configure:
    • Site Address: the same site as the trigger
    • File Identifier: Identifier from the trigger
  3. Open Advanced parameters and set Infer content type to Yes.

Get file content configuration

SharePoint Get file content action panel with Site Address set to the PDF4me Sharepoints site, File Identifier mapped to the trigger's Identifier token, and Infer content type set to Yes

Infer content type Yes is what hands the next action real PDF bytes instead of a generic blob.

The identifier is the join between the two steps. Use the trigger's Identifier field, not the file name or the path. Names repeat across folders and change when someone renames a document. The identifier does not.


Step 3: Why run OCR before extracting text?

Flow so far: SharePoint trigger plus Get file content.

A scanned page is an image. There is no text to extract until OCR puts a text layer on it. This action does that, and it is smart enough to leave already-readable PDFs alone.

  1. Add PDF - Convert PDF to editable PDF using OCR.
  2. Configure:
    • File Content: File Content from Get file content
    • File Name: the trigger's file name token
    • QualityType: Draft
    • OCR Only When Needed: true
    • Language: leave blank unless your documents are not in English
    • Is Async: No

OCR parameters

ParameterValue used hereWhat it controls
File ContentFile Content from Get file contentThe PDF bytes to process.
File Nametrigger file name tokenSource name, used for processing identification.
QualityTypeDraftRecognition effort. Draft is fast and accurate enough for clean scans. Move to High for poor originals.
OCR Only When NeededtrueSkips files that already have a text layer, so born-digital PDFs pass straight through.
LanguageblankHint for the recognition engine. Leave empty for English.
Is AsyncNoWaits for the result inline. Switch to Yes for very large documents.
PDF4me Convert PDF to editable PDF using OCR action panel with File Content from Get file content, File Name from the trigger, QualityType Draft, OCR Only When Needed true, Language blank, and Is Async No

QualityType is set to Draft here. On a clean scan it reads just as well as High and costs less time.

Tip. This is the slow step, 11 seconds in the run above against half a second for everything else. Start on Draft, check the text file, and only move to High if characters are coming back wrong. Raising quality on documents that did not need it is the easiest way to make this flow feel sluggish.


Step 4: How does Extract Text and Images return the text?

Flow so far: SharePoint trigger plus Get file content plus OCR.

This action reads the text layer and hands it back as an array called texts. Point it at the OCR output, not back at Get file content, or scanned pages come back empty.

  1. Add PDF - Extract Text and Images.
  2. Configure:
    • File Content: File Content from the OCR action
    • File Name: the trigger's file name token
    • Extract Text: Yes
    • Extract Images: No

Extract Text and Images parameters

ParameterValue used hereWhat it controls
File ContentFile Content from the OCR stepThe searchable PDF. Reusing Get file content's copy here is the single most common mistake.
File Nametrigger file name tokenSource name, carried through for identification.
Extract TextYesReturns the texts array.
Extract ImagesNoSkip embedded images. Set Yes only if you need them, it makes the response much larger.
PDF4me Extract Text and Images action panel with File Content mapped from the PDF4me OCR action, File Name from the SharePoint trigger, Extract Text set to Yes and Extract Images set to No

Look at the icons. File Content carries the PDF4me mark because it comes from OCR. File Name carries the SharePoint mark because it comes from the trigger.


Step 5: How do you turn the texts array into one string?

Flow so far: SharePoint trigger plus Get file content plus OCR plus Extract Text and Images.

texts is an array. A file needs a string. One join expression bridges the two.

  1. Add a Compose action.
  2. In Inputs, switch to the expression editor and paste:
join(body('PDF_-_Extract_Text_and_Images')?['texts'], decodeUriComponent('%0A'))
  1. Click Update.

The decodeUriComponent('%0A') is how you write a literal newline in a Power Automate expression. There is no escape sequence for it, so this is the idiom.

Compose configuration

Power Automate Compose action with the expression editor open showing join of the PDF Extract Text and Images texts array with decodeUriComponent percent zero A as the separator

The action name inside body() uses underscores for spaces and hyphens. Rename the action and this expression breaks.

This is the one line that decides whether the output is readable. Skip Compose and pass the array straight to Create file, and the text file will contain JSON brackets and escaped quotes rather than the document.


Step 6: How do you save the text as a .txt file in SharePoint?

Flow so far: SharePoint trigger plus Get file content plus OCR plus Extract Text and Images plus Compose.

The last step writes the joined string into a second library.

  1. Add SharePoint > Create file.
  2. Configure:
    • Site Address: same site as the trigger
    • Folder Path: /Shared Documents/RagText
    • File Name: the trigger's file name token followed by the literal text .txt
    • File Content: the Compose output token

SharePoint Create file configuration

SharePoint Create file action with Site Address PDF4me Sharepoints, Folder Path /Shared Documents/RagText, File Name built from the trigger file name token plus .txt, and File Content set to the Compose output token

File Content is the Compose output, carrying the purple data-operation icon, not anything from PDF4me. The text has already been assembled by this point.

Tip. The trigger's file name token already carries the .pdf extension, so appending .txt produces contract.pdf.txt, which is what the output folder above shows. That is harmless and it keeps the link to the source obvious. If you would rather have contract.txt, wrap the token in replace() and swap .pdf for .txt instead of appending.


Run the Flow and Verify

  1. Save the flow at the top right.
  2. Upload contract-sample.pdf into the input folder. The trigger polls, so give it a minute.
  3. Open the flow's run history and check all six actions carry a green tick. OCR will be the slow one.
  4. Open /Shared Documents/RagText. A .txt file should be sitting there. Open it and search for PDF4ME-CLEAN-TEST-2026. If that marker is present, OCR and extraction both worked end to end.

What did you actually build? A document ingestion pipeline. Every PDF that lands in the library becomes plain text automatically, which is the unglamorous prerequisite for anything that reads documents at scale: SharePoint search, a vector index, a retrieval augmented chatbot, or plain full text grep. If you only need the text inside the flow rather than on disk, the shorter Extract Text from PDFs in Power Automate walkthrough covers that with Dropbox.


Common Variations You Can Add Without Rebuilding

Filter before you download
Because the trigger returns metadata first, you can add a Condition on the file name or a column before Get file content runs. Non-PDF uploads then cost you nothing.
Keep the searchable PDF too
Add a second Create file that saves the OCR action's output. You get a text copy for machines and a searchable PDF for humans, from one run.
Write JSON instead of plain text
Change the Compose expression to build an object with the file name, the date, and the text, then save as .json. Most vector stores prefer metadata alongside the content.
Cloud flow vs the alternatives
See the comparison table below for how this differs from Power Automate Desktop and from AI Builder.
Cloud flow vs the alternativesRuns unattendedHandles scanned PDFsConnector tier
PDF4me in a Power Automate cloud flowYesYes, OCR built into the flowStandard
Power Automate Desktop PDF actionsOnly while the machine is onNo OCR in the base actionsStandard, plus a machine
AI Builder form processingYesYesPremium, credit metered

Common questions

Can Power Automate extract text from PDF?

Not on its own in a cloud flow. The PDF actions in Microsoft's documentation belong to Power Automate Desktop and are unavailable in cloud flows, which is why so many community threads on this question go unresolved. Adding the PDF4me connector gives a cloud flow a real Extract Text and Images action that returns the document's text as an array.

The whole extraction is one action. The surrounding five steps are just moving the file in and the text out.

How to extract text from PDF using Power Automate?

Trigger on the new file, fetch its bytes with Get file content, run Convert PDF to editable PDF using OCR so scanned pages get a text layer, then run Extract Text and Images with Extract Text set to Yes. That returns a texts array. Join it with a Compose expression if you want prose rather than an array.

Point the extraction step at the OCR action's output rather than the file you downloaded. Reusing the downloaded copy is the reason scanned documents come back empty.

Can Power Automate do OCR?

A cloud flow has no native OCR action. AI Builder offers one on a premium, credit-metered licence, and Power Automate Desktop has its own OCR engine tied to a machine. The PDF4me Convert PDF to editable PDF using OCR action runs in a standard-tier cloud flow with no machine involved.

Its OCR Only When Needed setting is worth knowing about. Set to true, it inspects each file and skips OCR when a text layer already exists, so a mixed library does not pay the cost on every document.

Why is Power Automate extract text from PDF not working?

Three causes cover almost every case. The document is a scan and never went through OCR, so there is genuinely no text to find. The extraction step is reading the downloaded file rather than the OCR output, which produces the same empty result on scanned input. Or the text arrived fine but was written to the file as a raw array, so it looks like JSON rather than a document.

Open the run history and inspect the Extract Text and Images output directly. If texts has content there, the problem is downstream in Compose or Create file.

How do you convert PDF to a text file for free?

For one document, any online converter will do it. The reason to build this flow is volume and repetition: it runs unattended on every file that lands in the folder, handles scans, and needs no one to be at a keyboard. PDF4me's free tier covers a meaningful number of documents per month, and every connector used here is standard tier, so there is no premium Power Automate licence involved.


Troubleshooting

The .txt file is created but it is empty

Extract Text and Images is reading the wrong file. Its File Content must come from the OCR action, carrying the PDF4me icon, not from Get file content. On a born-digital PDF both work, which is why this bug usually surfaces only once a real scan arrives.

The output looks like ["line one","line two"] instead of text

Create file is receiving the raw texts array. Its File Content must be the Compose output token. If Compose is present but still returning an array, check that the join expression has both arguments, the array and the separator.

Get file content fails with "file not found"

File Identifier is mapped to the wrong token. It needs the trigger's Identifier, not the file name, the path, or the item ID. Those look interchangeable in the dynamic content list and are not.

The flow keeps triggering itself

The output folder sits inside the folder the trigger watches, so each new text file starts another run. Keep RagInput and RagText separate, as siblings rather than nested.


Next Steps

The same six-step pattern (watch a folder, fetch, OCR, extract, flatten, save) turns any document library into a machine readable corpus.