Apache PDFBox Extract

Apache PDFBox Extract

Certified

Extract text from a PDF

Reads the text layer of a PDF from internal storage, for the whole document or a page range. Scanned PDFs without a text layer return empty text; render their pages with image.Render and run OCR instead.

yaml
type: io.kestra.plugin.pdfbox.text.Extract

Extract the text of the first five pages of an uploaded PDF

yaml
id: pdf_extract_text
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: extract
    type: io.kestra.plugin.pdfbox.text.Extract
    from: "{{ inputs.file }}"
    startPage: 1
    endPage: 5

  - id: log_text
    type: io.kestra.plugin.core.log.Log
    message: "{{ outputs.extract.text }}"

Extract text page by page from an encrypted PDF and store it in internal storage

yaml
id: pdf_extract_pages
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: extract
    type: io.kestra.plugin.pdfbox.text.Extract
    from: "{{ inputs.file }}"
    password: "{{ secret('PDF_PASSWORD') }}"
    perPage: true
    fetchType: STORE
Properties

The PDF to read, as an internal storage URI

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

Last page to read, inclusive

Defaults to the last page.

DefaultFETCH
Possible Values
STOREFETCHFETCH_ONENONE

How to return the text

FETCH (default) returns it in text and pages. STORE writes UTF-8 text files to internal storage and returns uri and pageUris; use it for long documents, since task outputs are limited in size. NONE returns only pageCount. FETCH_ONE is not supported.

Default1000

Maximum number of pages to read

The task fails instead of reading more pages than this; narrow the page range for longer documents. Default 1,000, between 1 and 100,000.

Password of an encrypted PDF

Defaultfalse

Also return the text of each page separately

When true, pages (or pageUris with fetchType: STORE) holds one entry per page in the range, in order. Default false.

Defaultfalse

Sort text by its position on the page

Helps with multi-column layouts and PDFs whose text is written out of reading order. Default false.

Default1

First page to read, starting at 1

Default 1.

Total number of pages in the document

SubTypestring

Internal storage URIs of each page's text file, when perPage is true and fetchType is STORE

SubTypestring

Text of each selected page, when perPage is true and fetchType is FETCH

Text of the selected pages, with fetchType: FETCH

Formaturi

Internal storage URI of the text file, with fetchType: STORE