Forum


Replies: 5   Views: 478
How to add exportformfields whne converting to pdf using libreoffice
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

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

Hi

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

Thanks

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

Hello,

The formsfields option available in the conversion plugin based on LibreOffice is false as default (https://www.phpdocx.com/api-documentation/format-conversion/convert-Word-docx-into-pdf-with-PHP).

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.

Regards.

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

Hi

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

Hello,

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

Regards.

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

According to this it's

https://help.libreoffice.org/latest/he/text/shared/guide/pdf_params.html?&DbPAR=SHARED&System=MAC

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

Hello,

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.

Regards.