PdfPageSplitter
Split PDFs pages so each pages are treated as individual documents.
Notes
May not work on all PDFs — encrypted ones in particular.
Each page produced carries a document.pdf.pageNumber field and a
document.pdf.numberOfPages field. The original PDF is kept alongside its
pages; set discardOriginal to true to keep only the pages.
To drop the original later in the pipeline instead, reject the documents that have no page number — those are the containers rather than the pages:
{
"if": {
"condition": {
"class": "BlankCondition",
"fieldMatcher": { "pattern": "document.pdf.pageNumber" }
},
"then": [
{ "handler": { "class": "Reject", "message": "Original PDF container" } }
]
}
}
By default this splitter applies only to documents whose content type is
application/pdf.
Should be used as a pre-parse handler.
Examples
The following example will split PDFs and will append the page number to the original PDF reference as "#page1", "#page2", etc.
- YAML
- JSON
- XML
handler:
class: PdfPageSplitter
referencePagePrefix: "#page"
{
"handler": {
"class": "PdfPageSplitter",
"referencePagePrefix": "#page"
}
}
<handler>
<class>PdfPageSplitter</class>
<referencePagePrefix>#page</referencePagePrefix>
</handler>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
class: PdfPageSplitter
contentTypeMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
discardOriginal: false
label: string
referencePagePrefix: string
{
"class": "PdfPageSplitter",
"contentTypeMatcher": {
"ignoreCase": false,
"ignoreDiacritic": false,
"matchEmpty": false,
"method": "BASIC",
"negateMatches": false,
"partial": false,
"pattern": "string",
"replaceAll": false,
"trim": false
},
"discardOriginal": false,
"label": "string",
"referencePagePrefix": "string"
}
<handler>
<class>PdfPageSplitter</class>
<contentTypeMatcher>
<ignoreCase>false</ignoreCase>
<ignoreDiacritic>false</ignoreDiacritic>
<matchEmpty>false</matchEmpty>
<method>BASIC</method>
<negateMatches>false</negateMatches>
<partial>false</partial>
<pattern>string</pattern>
<replaceAll>false</replaceAll>
<trim>false</trim>
</contentTypeMatcher>
<discardOriginal>false</discardOriginal>
<label>string</label>
<referencePagePrefix>string</referencePagePrefix>
</handler>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
contentTypeMatcher | TextMatcher | No | TextMatcher |
discardOriginal | boolean | No | false |
label | string | No | - |
referencePagePrefix | string | No | # |
Property Details
contentTypeMatcher
Restricts processing to documents whose content type matches the specified pattern. When not set, the handler applies to all content types.
discardOriginal
Discard the original document after the split is performed.
label
An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.
referencePagePrefix
Defines the prefix added before the page number in a document reference. Default is "#" such as: