Forum


Replies: 2   Views: 4873
Error converting 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 rstoeber  · 01-07-2018 - 20:32

Running PHP 7.0 on Ubuntu 16.04 and LibreOffice 5.1.6.2

New version of phpdocx 8.2 (Advanced) installed today.

phpdocx config file is modified to use libreoffice like so:

[transform]
method = "libreoffice"

; libreoffice installation path, absolute path
path = "/usr/bin/soffice"
 

Creating docx files directly and from templates (with modifications) works perfectly.

When I try to convert any docx file to pdf I get errors. From the documentation and forums it looks like the recommended code is like this:

$docx = new TransformDocAdvLibreOffice();

$docx->transformDocument($docxname, $pdfname);

But that generates this error:

PHP Fatal error:  Uncaught Exception: The chosen extension is not supported 

I have no idea what that means. What extension isn't supported?

If I remove the phpdocx code and instead do it myself, this works perfectly:

exec("/usr/bin/soffice --headless --convert-to pdf:writer_pdf_Export --outdir $pdfname $docxname");

I thought it would be easier/safer/more reliable to use the docx-pdf conversion function in phpdocx, but I can't get it working. I even tried following the instructions in the website section called Debugging LibreOffice. That tells me to run a sample script called sample_1.php but that doesn't provide anything helpful. That script just generates a different error:

PHP Warning:  rename(./example_text.pdf,example_text.pdf): No such file or directory in /var/www/staging-wgaccounts/phpdocx/classes/TransformDocAdvLibreOffice.php on line 138

Any advice?