Loopfour
Blocks

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

actionEditor labelWhat it does
pdf.readTextRead textReturns the text of each selected page, and all of it joined.
pdf.extractPagesExtract pagesSaves a PDF with only the selected pages, or returns it inline.
pdf.getInfoGet infoReturns 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 labelTypeUsed byMeaning
fileIdPDF FilestringAllId of a PDF in Files, such as {{steps.save_bill.file.id}}.
urlOr a LinkstringAllAn https URL to fetch the PDF from. Goes through Loopfour's outbound network policy, which refuses plain http and private addresses.
contentOr Inline ContentstringAllBase64 PDF bytes from an earlier step. Keep this for small files.
contentEncodingContent EncodingstringAllbase64 (default) or text, for content.
fileNameNot shownstringAllName to report for a url or content source. Default document.pdf.
pagesPagesstringreadText, extractPages1-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.
firstPagesFirst PagesnumberreadText, extractPagesPages to take from the front. Combines with the other page options.
lastPagesLast PagesnumberreadText, extractPagesPages to take from the end. Combines with the other page options.
mergePagesMerge PagesbooleanreadTextReported back as merged. Both pages and text are always returned.
outputReturnstringextractPagesfile (default) saves the PDF in Files and returns its id. content returns base64 in the step output.
baseNameSaved File NamestringextractPagesName to save under. A re-run with the same name replaces the file. Defaults to the source name plus the pages kept.
folderPathFolder PathstringextractPagesFolder to save in, such as Remittances/2026-11. Defaults to the source file's folder.
folderIdFolder IDstringextractPagesAn existing folder. With folderPath too, the path is created inside it.
maxSizeBytesMax Inline BytesnumberextractPagesCap for output: "content". At most 14680064 (14 MiB).

Output

pdf.readText:

FieldTypeMeaning
pagesstring arrayText of each selected page, in order.
textstringAll selected pages joined.
pagesReadnumber array1-based page numbers read.
pageCountnumberPages in the document.
mergedbooleanThe mergePages setting.
fileNamestringName of the file read.
sourceFileIdstringThe source file id, when the source was in Files.

pdf.extractPages:

FieldTypeMeaning
fileId, filePath, fileNamestringThe saved PDF, for output: "file". When no pages were dropped and no name or folder was set, fileId is the source file itself.
content, contentEncodingstringBase64 bytes, for output: "content".
pagesKeptnumber array1-based pages kept. Empty when the result has every page.
trimmedbooleantrue when pages were dropped.
pageCountnumberPages in the result.
sourcePageCountnumberPages in the source.
mimeType, sizeBytes, sourceFileIdFile 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.
  • readText reads 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 url and processing each have a 120-second limit.
  • extractPages with output: "content" fails when the result is larger than maxSizeBytes. Use output: "file" for large results.

On this page