Skip to content

PDF Activities

Version: 1.2.3  ·  ID: zoan-packages-pdf  ·  Author: Zoan Software

The PDF package reads and manipulates PDF files: extract text (and words with their coordinates), search content, read metadata, render pages to images, and merge, split, extract pages, rotate or watermark. It is widely used in document processes: reading PDF invoices, splitting a batch of documents, consolidating reports.

  • No session: each activity receives the path (path) of the file and works on it. There is no need to “open” or “close” the PDF.
  • The original is not modified: the manipulation activities (merge, rotate, watermark…) create a new file at the output path (or in the outputDir folder) you give, and return that path. The input PDF stays intact. If the output folder doesn’t exist, it is created; if the output file already exists, it is overwritten.
  • Runs on the robot’s machine: it uses no AI and no Zoan Cloud services.

Several activities let you specify pages with a range as text: you combine single numbers and hyphenated ranges, separated by commas. Pages are numbered from 1.

"1-3,5,7-9" → pages 1, 2, 3, 5, 7, 8 and 9
"all" → every page
RuleDetail
Rangesstart-end, both included. Spaces are allowed ("1 - 3, 5").
OrderPages are always processed in ascending order and without repeats: "5,1-2,2" = 1, 2, 5.
Invalid partsIgnored without error ("1,abc,3" = 1, 3; a reversed range like "5-3" adds no pages).
"all"Every page (case-insensitive). Same as not giving pages in PDF Get Words, PDF To Images and PDF Rotate.
List of numbersEvery activity that takes pages also accepts a list of numbers, such as the one returned by PDF Search Text: pages = foundPages or pages = new[] { 1, 3, 5 }. An item that isn’t a whole page number is an error ('pages' must contain whole page numbers; '…' is not one.). Since 1.2.4.
Pages that don’t existPDF Get Words, PDF To Images and PDF Extract Pages fail with Page(s) out of range: …; PDF Rotate too, since version 1.2.4 (it used to ignore them).

No activity in the package takes a password. A PDF with an open password can’t be read or transformed: the activity fails with the PDF library’s error. The same happens with a damaged file or one that isn’t a PDF. Ask for the document without a password at the source and, if the batch may contain such files, wrap the activity in a Try Catch to set them aside without stopping the process.

MessageCause and fix
File not found.The path doesn’t exist. Check it first with File Exists if the file may be missing.
'path' is required. (or 'output', 'outputDir', 'text'…)A required parameter was left empty or its expression returned null.
Page(s) out of range: …. The document has … pages.The range asks for pages the document doesn’t have. Get the total first with PDF Get Page Count.
'dpi' must be between 36 and 1200. Received: ….Resolution outside the supported range.
'…' must be a number. Received: …. / '…' must be true or false. Received: ….A numeric parameter (opacity, fontSize, margin, angle) or a yes/no one (caseSensitive) got a value that doesn’t work, typed or computed by an expression. Since 1.2.4.
PDF library error when opening the filePassword-protected, damaged or not a PDF. See Protected and damaged PDFs.
ActivityTypeOutputWhat it does
PDF Get Textpdf-get-textstringExtracts all the text of the PDF
PDF Get Text (Page)pdf-get-text-pagestringExtracts the text of one page
PDF Get Wordspdf-get-wordsListEvery word with its page and coordinates
PDF Get Page Countpdf-get-page-countintNumber of pages
PDF Get Metadatapdf-get-metadataDictionaryMetadata (title, author, dates…)
ActivityTypeOutputWhat it does
PDF Contains Textpdf-contains-textboolDoes it contain the text?
PDF Search Textpdf-search-textListWhich pages the text appears on
ActivityTypeOutputWhat it does
PDF Mergepdf-mergestringMerges several PDFs into one
PDF Splitpdf-splitListSplits each page into its own file
PDF Extract Pagespdf-extract-pagesstringExtracts specific pages into a new PDF
PDF Rotatepdf-rotatestringRotates pages (90/180/270°)
ActivityTypeOutputWhat it does
PDF To Imagespdf-to-imagesListRenders the pages to PNG files
ActivityTypeOutputWhat it does
PDF Createpdf-createstringCreates a new PDF from text
PDF Add Watermarkpdf-add-watermarkstringAdds a watermark to every page

Read a PDF invoice and extract its number with a regular expression:

PDF Get Text path = invoicePath → output: text
Set Variable name = number value = regexFind(text, "INV-\d+")
Log message = "Invoice: " + number