PDF Create
PDF Create
Section titled “PDF Create”Type: pdf-create · Package: PDF Activities v1.2.4 · Output: string
Creates a new PDF from text. It is a simple way to generate plain documents from the robot: a receipt, a summary, a process record. Returns the path of the PDF created.
How it works
Section titled “How it works”Writes content to a new PDF at output and returns the path of the file. It uses black Arial on white, at the fontSize size and with a line spacing of 1.4 times that size, starting at the top margin.
The content is written line by line, and each line maps to a line in the PDF:
- If you pass a text, every line break starts a new line. All three line endings work (
\n,\r\nand\r). - If you pass a list, each item is a line. If an item contains line breaks, it is split too.
Lines wider than the page are wrapped at word boundaries so they fit; a single word that doesn’t fit on its own (a long path, a hash) is broken by characters. Text never runs off the side of the page. When a page fills up, the text continues on a new one.
To force a page break, include a line with \f or {PAGE_BREAK} (only that on the line; surrounding spaces are allowed). That line is not written.
It creates the output folder if it doesn’t exist and overwrites the file if it already exists.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
output | string | — | Path of the PDF to create. |
content | string | List | — | Text content: a text, where each line break starts a new line, or a list of texts (one line each). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
title | string | — | Document title (the Title metadata, which the viewer shows in its tab). It is not written on the page. |
fontSize | number | 11 | Font size in points, greater than 0. It accepts a number or an expression. Since 1.2.4. |
margin | number | 2.0 | Page margin in centimetres, the same on all four sides, from 0 to less than 10.5. It accepts a number or an expression. Since 1.2.4. |
Output
Section titled “Output”Returns a string with the path of the PDF created (the same as output).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'fontSize' must be a number. Received: …. (or 'margin') | The typed value or the result of the expression isn’t a number. Since 1.2.4. |
'fontSize' must be greater than 0. Received: …. | Font size 0 or negative. Since 1.2.4. |
'margin' must be between 0 and 10.5 centimetres. Received: …. | Negative margin, or so large it leaves no room to write. Since 1.2.4. |
'output' is required. / 'content' is required. | The parameter was left empty or its expression returned null. An empty text ("") is valid: it creates a one-page blank PDF. |
| File system access error | No permission on the folder, or the output file is open in another program. |
A fontSize or margin value that isn’t a number counts as 0; make sure they are numbers.
Example
Section titled “Example”Generate a processing receipt:
PDF Create output = "C:/receipts/" + number + ".pdf" title = "Receipt " + number content = arr( "Processing receipt", "Number: " + number, "Date: " + now().ToString("yyyy-MM-dd HH:mm"), "Status: Processed successfully" ) → output: receiptPDF Add Watermark path = receipt output = receipt.Replace(".pdf", "-copy.pdf") text = "COPY"The same document with a text instead of a list — each \n is a line:
PDF Create output = "C:/receipts/" + number + ".pdf" content = "Processing receipt\n" + "Number: " + number + "\n" + "Status: Processed successfully"A two-page report, with the break marked as one more line:
PDF Create output = "C:/reports/summary.pdf" content = arr( "Process summary", "Records processed: " + total.ToString(), "{PAGE_BREAK}", "Annex: error details" )Related activities
Section titled “Related activities”- PDF Add Watermark — mark the document you created.
- Word — for richly formatted documents.