PALATINELABSDocsENES

Pages

↑↓ to moveEnter to openEsc to close

PDF package guide

Use PDF to read properties, text, form field values and embedded images, or to merge and split documents.

Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.

Jump to actions

Prerequisites

Shared fields

FieldEditor fieldType; default; required/optionalApplies toUse
filePathPDF pathStringdefault ""requiredpdfExtractField⁠, pdfExtractImage⁠, pdfExtractText⁠, pdfGetProperty⁠, pdfSplitDocumentAn existing PDF, e.g. samples/report.pdf⁠. A path of only spaces fails.
userSecureTextUser passwordCredentialdefault empty CredentialoptionalpdfExtractField⁠, pdfExtractImage⁠, pdfExtractText⁠, pdfGetProperty⁠, pdfMergeDocument⁠, pdfSplitDocumentThe PDF password, in the Credential password field. The username is ignored. Leave empty if the PDF is not protected. Merge uses the same password for every file.
ownerSecureTextOwner passwordCredentialdefault empty CredentialoptionalpdfExtractField⁠, pdfExtractImage⁠, pdfExtractText⁠, pdfGetProperty⁠, pdfMergeDocument⁠, pdfSplitDocumentAnother password to open the PDF. Used only if the user password is empty.
pageOptionPage rangePageOptiondefault ALLoptionalpdfExtractImage⁠, pdfExtractTextALL⁠: every page; selectedPages is ignored. SELECTED⁠: the pages in selectedPages⁠.
selectedPagesPages (e.g. 1, 3, 5-12)Stringdefault ""optionalpdfExtractImage⁠, pdfExtractText⁠, pdfSplitDocumentPages and ranges, e.g. 1, 3, 5-7⁠, split by commas or semicolons. Pages come in the order you write them, each once, and a range always counts up (7-5 gives 5, 6, 7). Pages that do not exist are skipped. The step fails if no page is left or an entry is not a number.
outputDirectoryFolder pathStringdefault ""requiredpdfExtractImage⁠, pdfSplitDocumentOutput folder, e.g. samples/parts⁠. It is created when a file is written.
filePrefixFile prefixStringdefault image (Extract image), split (Split)optionalpdfExtractImage⁠, pdfSplitDocumentStart of each file name, without a folder, e.g. part⁠. _1⁠, _2 and so on are added.
overwriteFileOverwrite files with the same name (Merge: Overwrite existing file)Booleandefault falseoptionalpdfExtractImage⁠, pdfExtractText⁠, pdfMergeDocument⁠, pdfSplitDocumentfalse⁠: the step fails if an output file exists. true⁠: the file is replaced. An action that writes many files can write some before a later name conflict fails the step.
OutputEditor fieldTypeApplies toUse
propertiesAssign PDF properties to a dictionary variableDictionarypdfExtractImage⁠, pdfExtractText⁠, pdfGetProperty⁠, pdfSplitDocumentString title⁠, author⁠, subject⁠, keywords⁠, creator⁠, producer⁠, creationDate⁠, modifiedDate⁠, version⁠; Number pages⁠; Boolean encrypted⁠. Missing text is empty; dates are text. Save it in Dictionary pdfInfo and read e.g. $pdfInfo.pages$⁠.
filesWritten image files (Extract image), Written files (Split)List of File valuespdfExtractImage⁠, pdfSplitDocumentThe files written, in order. It can be empty.

Actions

Decrypt document (pdfDecryptDocument)

Hidden. Kept only so old steps open. It always fails. The other actions can read protected PDFs.

Inputs

InputEditor fieldType; default; required/optionalUse
filePathPDF pathStringdefault ""requiredNot used.
userSecureTextUser/Owner passwordCredentialdefault empty CredentialoptionalNot used.
outputFileSave the decrypted PDF file asStringdefault ""requiredNot used. No file is written.
overwriteFileOverwrite files with the same nameBooleandefault falseoptionalNot used.

Outputs

None.

Example

An old step with filePath=samples/protected.pdf and outputFile=samples/open.pdf.

Expected result

The step fails with Palatine does not write decrypted copies of PDFs, even with the right password. No file is written.

Back to actions

Encrypt document (pdfEncryptDocument)

Hidden. Kept only so old steps open. It always fails.

Inputs

InputEditor fieldType; default; required/optionalUse
filePathPDF pathStringdefault ""requiredNot used.
userSecureTextUser passwordCredentialdefault empty CredentialoptionalNot used.
ownerSecureTextOwner passwordCredentialdefault empty CredentialoptionalNot used.
outputFileSave encrypted PDF asStringdefault ""requiredNot used. No file is written.
overwriteFileOverwrite files with the same nameBooleandefault falseoptionalNot used.

Outputs

None.

Example

An old step with filePath=samples/report.pdf and outputFile=samples/locked.pdf.

Expected result

The step fails with Palatine does not write encrypted PDFs. No file is written.

Back to actions

Extract field (pdfExtractField)

Read the field values of a fillable PDF form. It does not read other page text.

Inputs

Uses the shared fields: filePath, userSecureText, ownerSecureText.

Outputs

OutputEditor fieldType and use
fieldsSave the output to a variableDictionary of field names and String values. A text field gives its text, a checkbox true or false⁠, a radio button the chosen value, and a list the chosen values joined by , ⁠. Fields inside fields use dots in their names.

Example

Use samples/form.pdf with a text field customer that holds Sample Company and a checked checkbox approved. Set filePath=samples/form.pdf. Save fields in Dictionary formData.

Expected result

$formData.customer$ is Sample Company and $formData.approved$ is String true. A PDF without a form gives an empty Dictionary. Signature and button fields give empty text.

Back to actions

Extract image (pdfExtractImage)

Save the images inside the chosen pages as image files. It does not turn pages into images.

Inputs

InputEditor fieldType; default; required/optionalUse
imageFileTypeType of image to be converted toImageFileTypedefault PNGoptionalPNG⁠, TIFF⁠, BMP⁠, JPEG or GIF⁠. WMF⁠, EMF and EXIF are in the list but fail when an image is written. JPEG files end in .jpg⁠.
jpegQualityJPEG qualityNumberdefault 90optional1 to 100⁠; other values change to the nearest limit. Only for JPEG⁠.
imageColorTypeImage outputImageColorTypedefault RGBoptionalRGB keeps the colors. GRAY makes the image gray.
resolutionXX Resolution(dpi)Numberdefault 96optionalHorizontal DPI saved in the file. Used only when X and Y are both above 0⁠. It does not change the image size.
resolutionYY Resolution(dpi)Numberdefault 96optionalVertical DPI saved in the file. Same rule as X.

Also uses the shared fields: filePath, userSecureText, ownerSecureText, pageOption, selectedPages, outputDirectory, filePrefix, overwriteFile.

Outputs

Returns the shared fields: properties, files.

Example

Use samples/pictures.pdf with one image on page 1. Set filePath=samples/pictures.pdf, pageOption=SELECTED, selectedPages=1, imageFileType=PNG, imageColorType=RGB, outputDirectory=samples/images, filePrefix=figure, overwriteFile=false, resolutionX=96, resolutionY=96. Save files in images and properties in pdfInfo.

Expected result

images has the File samples/images/figure_1.png. A PDF with only text gives an empty List and may create no folder. Images the package cannot read are skipped. It fails with an output type that cannot be written, an existing file when overwrite is off, or pages that do not exist.

Back to actions

Extract text (pdfExtractText)

Read the text of the chosen pages into a String and a UTF-8 file. There is no OCR.

Inputs

InputEditor fieldType; default; required/optionalUse
extractTextTypeText typeTextTypedefault PLAINoptionalPLAIN⁠: text as stored. STRUCTURED⁠: text in reading order.
outputFileExport data to text fileStringdefault ""optionalText file, e.g. samples/report.txt⁠, written as UTF-8. Required, even though the editor shows it as optional.

Also uses the shared fields: filePath, userSecureText, ownerSecureText, pageOption, selectedPages, overwriteFile.

Outputs

OutputEditor fieldType and use
textExtracted textString with the text of the chosen pages, also written to outputFile⁠. Up to 16,777,216 characters.

Also returns the shared fields: properties.

Example

Use a three-page samples/report.pdf with PALATINE PAGE 1, PALATINE PAGE 2 and PALATINE PAGE 3. Set filePath=samples/report.pdf, extractTextType=PLAIN, pageOption=SELECTED, selectedPages=2-3, outputFile=samples/report.txt, overwriteFile=false. Save text in reportText and properties in pdfInfo.

Expected result

The String and the file have the text of pages 2 and 3, with a new line between pages that have text, and nothing from page 1. Spaces depend on the PDF. A scan with no text gives empty text and still writes the file. It fails with an empty output path, no pages left, or an existing file when overwrite is off.

Back to actions

Get property (pdfGetProperty)

Read the document details and page count, e.g. before you extract or split.

Inputs

Uses the shared fields: filePath, userSecureText, ownerSecureText.

Outputs

Returns the shared fields: properties.

Example

Use an unprotected three-page samples/report.pdf with title Training Report. Set filePath=samples/report.pdf and leave both passwords empty. Save properties in Dictionary pdfInfo.

Expected result

$pdfInfo.title$ is Training Report, $pdfInfo.pages$ is 3 and $pdfInfo.encrypted$ is false. It fails with a file that is not a PDF, a wrong password, or a PDF over the limits.

Back to actions

Merge documents (pdfMergeDocument)

Join all pages of two or more PDFs, in List order. One password is used for all files. You cannot choose pages per file.

Inputs

InputEditor fieldType; default; required/optionalUse
pdfDocumentListPDF documentsListdefault []requiredList of two or more PDF paths in merge order, e.g. $documents$ with String items samples/a.pdf and samples/b.pdf⁠. Each file adds all its pages.
outputFileOutput file pathStringdefault ""requiredOutput file, e.g. samples/result.pdf⁠. Missing folders are created. Use a path that is not one of the sources.

Also uses the shared fields: userSecureText, ownerSecureText, overwriteFile.

Outputs

OutputEditor fieldType and use
fileMerged fileFile with the full output path.

Example

Use samples/a.pdf and samples/b.pdf, two pages each, in List documents in that order. Set pdfDocumentList=$documents$, outputFile=samples/merged.pdf, overwriteFile=false. Save file in merged.

Expected result

merged points to a four-page PDF: the pages of a.pdf, then the pages of b.pdf. It fails with fewer than two files, a file that cannot be read, a wrong password, more than 10,000 pages, or an existing output file when overwrite is off.

Back to actions

Split document (pdfSplitDocument)

Split a PDF by page count, chosen pages, blank separator pages or bookmark level. File numbers start at 1.

Inputs

InputEditor fieldType; default; required/optionalUse
splitDocumentOptionsOutput file creation optionsSplitOptiondefault PAGES_PER_FILEoptionalPAGES_PER_FILE⁠: groups of pages in a row. SELECTED_PAGES⁠: the chosen pages in one PDF. BLANK_PAGE_SEPARATOR⁠: splits at pages with no letters and no images, and drops those pages. BOOKMARK_LEVEL⁠: a new part at each bookmark of the chosen level; pages before the first bookmark are kept.
pageCountPerFileNumber of pages per extracted PDFNumberdefault 1optionalPages per file for PAGES_PER_FILE⁠. Below 1 uses 1⁠. The last file can have fewer pages.
bookmarkLevelBookmark LevelNumberdefault 1optionalBookmark level for BOOKMARK_LEVEL⁠; 1 is the top. Below 1 uses 1⁠. The step fails if there is no bookmark at that level.

Also uses the shared fields: filePath, userSecureText, ownerSecureText, selectedPages, outputDirectory, filePrefix, overwriteFile.

Outputs

Returns the shared fields: properties, files.

Example

Use a four-page samples/report.pdf. Set filePath=samples/report.pdf, splitDocumentOptions=PAGES_PER_FILE, pageCountPerFile=2, outputDirectory=samples/parts, filePrefix=part, overwriteFile=false. Save files in parts and properties in pdfInfo.

Expected result

parts has part_1.pdf (pages 1-2) and part_2.pdf (pages 3-4) in samples/parts. SELECTED_PAGES writes one file, in the order you wrote the pages. With blank separators, empty parts are not written, and a PDF of only blank pages gives an empty List. It fails if there is no bookmark at the chosen level or a later file name exists.

Four PDF pages split into part_1.pdf with pages 1-2 and part_2.pdf with pages 3-4.
With pageCountPerFile=2, each output keeps two consecutive pages. View full size

Back to actions