How to enable PDF forms in the Conversion API?


I’m trying to convert an ODT to a PDF with editable form fields using the Conversion API.

To generate the ODT in desktop LibreOffice you can just place a form text box (View > Toolbars > Form controls) and then invoke export to PDF (File > Export As > Export as PDF…) making sure to enable the “Create PDF form” checkbox in the export dialog.

Moreover, in a desktop command-line scenario you can use the --convert-to option, which generates the editable PDF form correctly, without the need for any options:

libreoffice --convert-to pdf --outdir . test_form.odt

But Coolwsd’s Conversion API generates a PDF without form fields.

So I dug into LibreOffice’s source code and I found the relevant property in the PDF export filter, it’s called “ExportFormFields” and it appears to be set by default to true (same file, line 106.)

I tried setting the option explicitly to true using the options parameter, which if I understand correctly, should be a JSON:

curl -sS -F data=@test_form.odt -F options='{"ExportFormFields":true}' -o test_form.pdf

and I verified in the logs it is being passed to LOK:

kit-27722-27720 2023-03-23 16:28:16.687113 +0000 [ kitbroker_001 ] DBG ToMaster-001: Calling LOK's saveAs with URL: [], Format: [pdf], Filter Options: [{"ExportFormFields":true}]| kit/ChildSession.cpp:2542

but the converted PDF still has no form fields.

I checked in the Python UNO documentation, which also lists the ExportFormFields option as defaulting to true.

At this point I’m lost. Does anybody have any idea where this option is getting lost? Why does it work with UNO and the commandline --convert-to, but not with the Conversion API?