Forum


Replies: 3   Views: 4759
Using transformdoc to transform docx 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 bre-europe  · 16-11-2017 - 16:06

Hi,

we started using the namespaced premium version of phpdocx 7.5. We use it within a CakePHP project, I copied phpdocx's sources to the vendors folder, setup the classmap path in composer.json and ran composer dump-autoload.

When evaluating the test version, I understood that the conversion plugin was not included. Only know that we bought a license I learned that for using TransformDocAdv (or its decessors) you need OpenOffice or LibreOffice running.

So now I'd like to try to convert with the class TransformDoc, because that seems to be able to do the trick without any external software.

Here is a code snippet:

$transform  = new \Phpdocx\Transform\TransformDoc();
$transform->setstrFile('/path/to/source.docx');
$transform->generatePDF('/path/to/dest.pdf');

First I received an error that the class DOMPDF was not found in TransformDoc.inc on line 320. As this class resides in a subfolder of /lib/pdf/, I added that path to the classmap of composer.json and did another composer dump-autoload.

After that I got another error:

 Call to undefined function clear_object() in /[…]/phpdocx/lib/pdf/include/frame_tree.cls.php on line 105

Could someone tell me how to configure composer so that all necessary classes/functions can be found?

 

Posted by admin  · 16-11-2017 - 16:46

Hello,

Since phpdocx 3, the recommended method to transform DOCX to PDF and other document formats is transformDocument (or transformDocxUsingMSWord if you can use a Windows Server with MS Word and PHP COM functions).
If you need help to install and configure the conversion plugin, please read the information available on https://www.phpdocx.com/documentation/conversion-plugin. The steps to install and configure the conversion are very easy, but you can also write to contact[at]phpdocx.com and the dev team will install it if you send a remote access to your server.

Regards.

Posted by bre-europe  · 23-11-2017 - 18:28

Thanks for the reply. So using the class \Phpdocx\Transform\TransformDoc and its function generatePDF() is not an option at all?

Posted by admin  · 24-11-2017 - 07:27

Hello,

It's a solution only for very simple DOCX documents. To use that class we recommend you to use the generateHTML method and then use the latest version of DOMPDF or TCPDF to transform the HTML to PDF (the TransformDoc class is available in the trial package too).

Anyway, the recommended solution to transform DOCX to PDF among other document formats is the conversion plugin available in Advanced and Premium licenses.

Regards.