Skip to content

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.

  1. Takes the document at path and decides where to save the PDF: at outputPath or, if you omit it, in the same folder and with the same name as the document, with a .pdf extension. Relative paths are resolved against the robot’s working folder.
  2. Converts with the engine set in engine. With auto (default) it tries LibreOffice first and, if it is missing or fails, Microsoft Word.
  3. 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).
ParameterTypeDefaultDescription
pathstring—Path of the document to convert (.docx, .doc, .rtf, .odt).
ParameterTypeDefaultDescription
outputPathstring—Target .pdf path. If omitted: the same folder and name as the document with a .pdf extension.
enginestring"auto"Conversion engine: auto · libreoffice · word. auto tries LibreOffice and then Microsoft Word; any other value is treated as auto.

Returns a string with the full path of the generated PDF.

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 = true
Word Find & Replace path = "C:/letters/900123456.docx" find = "{NAME}" replace = customer.name
Word to PDF path = "C:/letters/900123456.docx" → output: pdfPath
Log message = "PDF ready at " + pdfPath

Generate 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 = attendees
Word to PDF path = "C:/minutes/committee.docx" outputPath = "C:/minutes/pdf/committee.pdf" → output: pdfPath

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 |:

MessageCause 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.