Forum


Replies: 7   Views: 841
Transform document to pdf
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 calcina  · 28-08-2022 - 15:34

I have a problem, it simply does not work for me to convert a Docx Document to PDF under any method.
Please help me.

Posted by admin  · 28-08-2022 - 17:29

Hello,

On https://www.phpdocx.com/documentation/conversion-plugin you can read the steps to install, use and debug the conversion plugin. For futher support please post what conversion plugin are you using and if you get some PHP error or notice.

Regards.

Posted by calcina  · 29-08-2022 - 21:57

The transform method 'native'.

Using dompdf allowed me to convert only normal plain text, otherwise I get the following error:

Fatal error: Uncaught Error: Cannot use object of type Dompdf\FrameDecorator\Inline as array in C:\wamp64\www\phpdocx\Classes\Phpdocx\Transform\TransformDocAdvPDF.php on line 486


How could I use the 'native' method to transform documents while maintaining their content and visual appearance? It seems to me that Libre Office is the recommended one.

I think that the 'libreoffice' conversion plugin necessarily works on 'Dedicated Hosts' due to the configuration issue, is it possible that it works on 'Shared Hosts'?

Thank you very much

Posted by admin  · 30-08-2022 - 05:48

Hello,

Please do not use dompdf 2 that was released after phpdocx 13 and it's not fully compatible. Use dompdf 1.2.2 or a previous version; or set the addHeadersAndFooters option as false.

The native conversion plugin supports a set of contents and styles detailed on https://www.phpdocx.com/documentation/conversion-plugin/preparing-the-templates-for-its-conversion (Supported OOXML tags and attributes when using the native method section).
The recommended conversion plugin is the one based on LibreOffice, that requires installing LibreOffice (https://www.phpdocx.com/documentation/conversion-plugin/conversion-plugin-installation-and-set-up), some shared hosting allow installing it, we recommend you contact them, or use a VPS (Amazon and Azure has free tiers for a whole year) or a dedicated server to install it.

Regards.

Posted by calcina  · 30-08-2022 - 12:26

Deleted by calcina · 30-08-2022 - 15:19

Posted by calcina  · 30-08-2022 - 16:42

Well, now with the previous version of dompdf the conversion to PDF does work for me, but it still doesn't keep the original design such as typography, borders, orientation and settings in general.

In my particular case, I have a template .docx

$docx = new Phpdocx\Create\CreateDocxFromTemplate('InvoiceTemplate.docx');

Replace some variables

$docx->replaceVariableByText($variablesFooters, $options);

Then convert to PDF, without losing any style, keeping everything in its original appearance.

$docx->transformDocument('Invoice.docx', 'Invoice.pdf');

What solution could help me specifically?
Is libreoffice the only one that could help me?

Posted by admin  · 30-08-2022 - 16:47

Hello,

If the DOCX to be transformed uses contents or styles not supported in the native conversion plugin (supported contents and styles by the native conversion plugin are detailed on https://www.phpdocx.com/documentation/conversion-plugin/preparing-the-templates-for-its-conversion), you need to use the conversion plugin based on LibreOffice.

If you send your DOCX to contact[at]phpdocx.com we'll check it, but from the information you have posted, the solution seems to use the conversion plugin based on LibreOffice.

Regards.

Posted by calcina  · 30-08-2022 - 22:14

Thanks much! I'll  try with that