Replies: 5   Views: 86
How to add exportformfields whne converting to pdf using libreoffice

Posted by rabol  · 30-01-2024 - 06:21


What is the correct way to pass 'ExportFormFields=false' when conveting word to PDF using Libre Office?


Posted by admin  · 30-01-2024 - 09:55


The formsfields option available in the conversion plugin based on LibreOffice is false as default (

If you want to use this option, you need to add macro in your LibreOffice home folder and enable the option when calling transformDocument.
Please check the macros-libreoffice folder included in the package. In this folder you can read all information about adding and using macros with the conversion plugin based on LibreOffice.


Posted by rabol  · 07-02-2024 - 07:07


Sorry, I can se tyhat It might not be totally clear what I would like to achive

on the commandline it's possible to have an option ExportFormFields=false, how do I add that when I call the transformDocumnent() method

The problem is that, if there is there are fields - like Document title or author that is inserted, or form fileds then LibreOffice marks the PDF with something called 'NeedAppreance' which intefeer with LTV signing of PDF's

So I need to pass this commandline option in order to ensure that LibreOffice convert the fields ttext

Posted by admin  · 07-02-2024 - 08:41


Thanks for sending more information about your question.

There's no option in phpdocx to set the internal ExportFormFields option available in LibreOffice as false. When the formsfields option in transformDocument is set as true, phpdocx uses the ExportFormFieldsToPdf macro to do the transformation, otherwise the default conversion is done.

We have moved this question to the dev team to consider adding a new option in phpdocx to set ExportFormFields as false in a future release of phpdocx.
To set ExportFormFields as false you could use one of the following approaches:

  • Use the ExportFormFieldsToPdf macro ((macros-libreoffice/macros/Export forms when transforming to PDF.txt) available in phpdocx but changing it to disable this option:
oPropertyDataValue.Name = "ExportFormFields"
oPropertyDataValue.Value =  0
soffice --headless --convert-to 'pdf:writer_pdf_Export:{"ExportFormFields":{"type":"boolean","value":"false"}}' --outdir /path/outputs/ /path/document.docx


Posted by rabol  · 11-02-2024 - 08:14

According to this it's

it's supported in the current version, the only thing that is needed is that transformDocument() supports all commandline options.

Posted by admin  · 11-02-2024 - 09:25


phpdocx supports many LibreOffice options, but some specific options are not supported in the current stable version of phpdocx. If you need to use a not supported option, then you need to call LibreOffice with a custom command. We have moved this topic to the Suggestions board, so the dev team can consider adding this new feature in the stable release of phpdocx.