PDF Create
PDF Create
Section titled “PDF Create”Type: pdf-create · Package: PDF Activities v1.0.0 · Output: string
Create a new PDF from text. It is a simple way to generate simple documents from the bot: a receipt, a summary, a process record. Returns the path of the created PDF.
How it works
Section titled “How it works”Writes the content to a new PDF in output and returns the file path.
Content is written line by line, and one line maps to one line of 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 element is a line. If an element contains line breaks, those are split too.
Lines longer than the page width are wrapped at word boundaries so they fit; a single word that does not fit on its own (a long path, a hash) is split by characters. Text never runs off the side of the page.
To force a page break, include a line with \f or {PAGE_BREAK}.
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
output | expression | Path of the PDF to create. |
content | expression | Text content: a text, where every line break starts a new line, or a list of texts (one line each). |
Optional parameters
Section titled “Optional parameters”| Parameter | Editor | Description |
|---|---|---|
title | expression | Document title (metadata). |
fontSize | number | Font size in points. By default 11. |
margin | number | Page margin in centimeters. By default 2.0. |
Output
Section titled “Output”Returns a string with the path of the created PDF.
Example
Section titled “Example”Generate proof of processing:
PDF Create output = = "C:/comprobantes/" + numero + ".pdf" title = = "Comprobante " + numero content = = arr( "Comprobante de procesamiento", "Número: " + numero, "Fecha: " + now().ToString("yyyy-MM-dd HH:mm"), "Estado: Procesado correctamente" )The same document using a text instead of a list — each \n is a line:
PDF Create output = = "C:/comprobantes/" + numero + ".pdf" content = = "Comprobante de procesamiento\n" + "Número: " + numero + "\n" + "Estado: Procesado correctamente"A two-page report, with the break written as just another line:
PDF Create output = "C:/informes/resumen.pdf" content = = arr( "Resumen del proceso", "Registros procesados: " + total.ToString(), "{PAGE_BREAK}", "Anexo: detalle de errores" )Related activities
Section titled “Related activities”- PDF Add Watermark — mark the created document.
- Word — for richly formatted documents.