PDF block
Configure the PDF block to extract text and pages from a PDF document, with the operations it supports and the output each one returns.
The PDF block reads the text of a PDF, saves a copy cut down to selected pages, or reports how many pages it has. It reads the text layer; it does not recognise text in scanned images. In a workflow definition it is a step with type: "action" and action set to pdf.readText, pdf.extractPages or pdf.getInfo. For the plain-language guide, see Read PDF documents.
When to use it
- Pull the text of an invoice or statement so an AI Agent step can extract fields from it.
- Keep only the remittance page of a long payment pack before sending it on.
- Check the page count first, then read only the last pages.
For a scanned document, pass the file to an AI Agent step as a document instead.
Operations
action | Editor label | What it does |
|---|---|---|
pdf.readText | Read text | Returns the text of each selected page, and all of it joined. |
pdf.extractPages | Extract pages | Saves a PDF with only the selected pages, or returns it inline. |
pdf.getInfo | Get info | Returns page count, size and whether the PDF is encrypted, without reading text. |
Configuration
Set one source. When more than one is set, fileId wins.
Field (config key) | Editor label | Type | Used by | Meaning |
|---|---|---|---|---|
fileId | PDF File | string | All | Id of a PDF in Files, such as {{steps.save_bill.file.id}}. |
url | Or a Link | string | All | An https URL to fetch the PDF from. Goes through Loopfour's outbound network policy, which refuses plain http and private addresses. |
content | Or Inline Content | string | All | Base64 PDF bytes from an earlier step. Keep this for small files. |
contentEncoding | Content Encoding | string | All | base64 (default) or text, for content. |
fileName | Not shown | string | All | Name to report for a url or content source. Default document.pdf. |
pages | Pages | string | readText, extractPages | 1-based pages and ranges, such as 1-5, 8, 11-13. A range past the end is shortened; a single page past the end is dropped. Empty means the whole document. |
firstPages | First Pages | number | readText, extractPages | Pages to take from the front. Combines with the other page options. |
lastPages | Last Pages | number | readText, extractPages | Pages to take from the end. Combines with the other page options. |
mergePages | Merge Pages | boolean | readText | Reported back as merged. Both pages and text are always returned. |
output | Return | string | extractPages | file (default) saves the PDF in Files and returns its id. content returns base64 in the step output. |
baseName | Saved File Name | string | extractPages | Name to save under. A re-run with the same name replaces the file. Defaults to the source name plus the pages kept. |
folderPath | Folder Path | string | extractPages | Folder to save in, such as Remittances/2026-11. Defaults to the source file's folder. |
folderId | Folder ID | string | extractPages | An existing folder. With folderPath too, the path is created inside it. |
maxSizeBytes | Max Inline Bytes | number | extractPages | Cap for output: "content". At most 14680064 (14 MiB). |
Output
pdf.readText:
| Field | Type | Meaning |
|---|---|---|
pages | string array | Text of each selected page, in order. |
text | string | All selected pages joined. |
pagesRead | number array | 1-based page numbers read. |
pageCount | number | Pages in the document. |
merged | boolean | The mergePages setting. |
fileName | string | Name of the file read. |
sourceFileId | string | The source file id, when the source was in Files. |
pdf.extractPages:
| Field | Type | Meaning |
|---|---|---|
fileId, filePath, fileName | string | The saved PDF, for output: "file". When no pages were dropped and no name or folder was set, fileId is the source file itself. |
content, contentEncoding | string | Base64 bytes, for output: "content". |
pagesKept | number array | 1-based pages kept. Empty when the result has every page. |
trimmed | boolean | true when pages were dropped. |
pageCount | number | Pages in the result. |
sourcePageCount | number | Pages in the source. |
mimeType, sizeBytes, sourceFileId | File facts. |
pdf.getInfo: pageCount, fileName, sizeBytes, encrypted, sourceFileId.
Example
This workflow reads the first two pages of a bill saved in Files and asks an AI Agent step to extract the totals.
{
"name": "Read bill totals",
"trigger": { "type": "api" },
"steps": [
{
"id": "read_bill",
"type": "action",
"name": "Read first pages",
"action": "pdf.readText",
"config": { "fileId": "{{input.fileId}}", "firstPages": 2 }
},
{
"id": "extract_totals",
"type": "agent",
"name": "Extract totals",
"config": {
"prompt": "From this bill text, return the subtotal, tax and total.\n\n{{steps.read_bill.text}}",
"outputSchema": {
"type": "object",
"properties": {
"subtotal": { "type": "number" },
"tax": { "type": "number" },
"total": { "type": "number" }
}
}
}
}
]
}Errors and limits
- A source that is not a PDF fails the step. Sources over 96 MiB are refused.
readTextreads at most 500 pages per run. A whole document over 500 pages fails; select pages instead.- Extracted text is capped at 10 MiB and the serialized result at 20 MiB.
- Fetching a
urland processing each have a 120-second limit. extractPageswithoutput: "content"fails when the result is larger thanmaxSizeBytes. Useoutput: "file"for large results.
Data Table block
Configure the Data Table block to query, insert, update and delete rows in a Loopfour table from a workflow, with the output of each one.
Stagehand block
Configure the Stagehand browser block to act in a web portal from a workflow: the instructions, settings and output it returns to the run.
Loopfour