Trigger PDF creation from API and replace placeholder

Hello,

I’m pretty new to collabora.

I would like to know if it’s possible to trigger a pdf creation on collabora, via some API call, to transform a .docx document into PDF while also replacing some fields values in the source document?

I currently have a Nextcloud 29.0.4.1 installed with collabora Collabora Online Development Edition 24.04.5.2

My need, is to obtain a PDF from a template with some placeholder replaced. Like, name, first-name, date, address, etc.

Any hit or suggestion are welcome. :wink:

Regards,
Sylvain.

Hi @Sylvain, welcome to the Collabora Online forums!

I came across a solution that might be useful for your needs, involving the REST API for document conversion. From what I understand, there may be some adjustments you’ll need to make, such as replacing placeholders with values before converting, but I’m confident you can get it working!

Here’s a suggested approach:

  1. Use a scripting language like Python to open the .docx template, replace the placeholders with the required values, and save the updated document. The python-docx library can help with this:

  2. Once the document is updated, you can use the Collabora Online REST API to convert it to PDF.

For reference, check out:

Cheers,
Darshan