Word to PDF
Word to PDF
Section titled “Word to PDF”Type: word-to-pdf · Package: Word Activities v1.0.4 · Output: string
Converts a Word document to PDF: the letter, contract or minutes you just generated, ready to send or archive without anyone being able to edit it. It accepts .docx, .doc, .rtf and .odt, and returns the path of the generated PDF.
How it works
Section titled “How it works”- Takes the document at
pathand decides where to save the PDF: atoutputPathor, if you omit it, in the same folder and with the same name as the document, with a.pdfextension. Relative paths are resolved against the robot’s working folder. - Converts with the engine set in
engine. Withauto(default) it tries LibreOffice first and, if it is missing or fails, Microsoft Word. - Returns the full path of the PDF.
If a PDF already exists at the target path, it is overwritten. Missing folders are created. The original document is not changed.
- LibreOffice runs in the background, with no windows, using its own temporary profile: it works even if LibreOffice is open on the machine. Available on Windows and Linux.
- Microsoft Word opens hidden, exports the PDF and closes without saving changes to the document. Windows only.
- The activity waits for the conversion to finish; it has no timeout of its own (it honors the run’s cancellation).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path of the document to convert (.docx, .doc, .rtf, .odt). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
outputPath | string | — | Target .pdf path. If omitted: the same folder and name as the document with a .pdf extension. |
engine | string | "auto" | Conversion engine: auto · libreoffice · word. auto tries LibreOffice and then Microsoft Word; any other value is treated as auto. |
Output
Section titled “Output”Returns a string with the full path of the generated PDF.
Example
Section titled “Example”Fill in a letter from a template and convert it to PDF:
Copy File source = asset("letter_template.docx") destination = "C:/letters/900123456.docx" overwrite = trueWord Find & Replace path = "C:/letters/900123456.docx" find = "{NAME}" replace = customer.nameWord to PDF path = "C:/letters/900123456.docx" → output: pdfPathLog message = "PDF ready at " + pdfPathGenerate a new document and save the PDF to another folder:
Word Create path = "C:/minutes/committee.docx" └─ body: Word Append Paragraph text = "Committee minutes" style = Title Word Append Table table = attendeesWord to PDF path = "C:/minutes/committee.docx" outputPath = "C:/minutes/pdf/committee.pdf" → output: pdfPathCommon errors
Section titled “Common errors”When no engine manages to convert, the message is Could not convert the document to PDF. followed by the reason from each engine tried, separated by |:
| Message | Cause and fix |
|---|---|
File not found. | The path does not exist on the machine where the robot runs. |
'path' is required. | path is missing or the expression returned nothing. |
LibreOffice: 'soffice' not found (install LibreOffice or set ZOAN_SOFFICE_PATH). | LibreOffice is not installed or not where it is looked for. Install it or set ZOAN_SOFFICE_PATH. |
LibreOffice: LibreOffice could not convert the document (exit …) | LibreOffice could not open or convert the file (damaged, password-protected). Open it by hand to check it. |
Word: Microsoft Word is not installed. | Conversion with Word was attempted and it is not installed. |
Word: COM automation requires Windows. | The word engine only works on Windows. On other systems, use LibreOffice. |
Related activities
Section titled “Related activities”- Word Create / Word Save — generate and save the document before converting.
- Excel to PDF — the same for Excel workbooks.
- PDF — work with the generated PDF.