Forum


Replies: 7   Views: 4662
Pdf conversion and download
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 davelavinsky  · 21-04-2016 - 10:58

Im using Coporate 5.5. My code goes like this :

if (isset($_GET['output']))
{
    if ($_GET['output'] == "pdf")
    {
        $docx->enableCompatibilityMode();
        $docx->createDocx('temp/Business Plan');
        $docx->transformDocument('temp/Business Plan.docx', 'temp/Business Plan.pdf');
    }
    else
     $docx->createDocxAndDownload('temp/Business Plan');
}
else
 $docx->createDocxAndDownload('temp/Business Plan');

1. No PDF found in temp folder.

2. Is there a transformDocumentAndDownload like in createDocxAndDownload ?

Posted by admin  · 21-04-2016 - 11:55

Hello,

Please follow the steps explained on:

http://www.phpdocx.com/documentation/conversion-plugin

to install and debug the conversion plugin.

About transformDocumentAndDownload, there's no method. I have added a task to consider adding it, but it can be done easily using a PHP header, this is something like:

header('Content-type:application/pdf');

header('Content-Disposition:attachment;filename="file.pdf"');

readfile('file_src.pdf');

Regards.

Posted by davelavinsky  · 21-04-2016 - 12:49

Im looking at http://www.phpdocx.com/documentation/conversion-plugin/conversion-plugin-installation-and-set-up

For example, type this configuration to use LibreOffice:

Where ? Where is this file and what is the name of it ?

Posted by admin  · 21-04-2016 - 13:44

Hello,

It's explained on that same page:

If you choose LibreOffice instead of OpenOffice, you must modify the config/phpdocxconfig.ini configuration file after installing the conversion plugin.

Regards.

Posted by davelavinsky  · 21-04-2016 - 14:57

Ok, thanks, I got to know where the file is.

Im testing this on my localhost, I have temp_path, code, value set including

method = "libreoffice"

path = "/usr/bin/libreoffice"

But now I get this :

Warning: rename(temp/Business Plan.pdf,temp/Business Plan.pdf): No such file or directory in /home/username/www/3rdParty/phpdocx-corporate-5.5/classes/TransformDocAdvLibreOffice.inc on line 131

I've chmod'd 777 the temp directory.

Posted by davelavinsky  · 21-04-2016 - 17:35

The sample code at http://www.phpdocx.com/documentation/conversion-plugin/running-the-first-example-and-available-options works in CLI mode. The rename error occurs only in the browser.

Posted by davelavinsky  · 22-04-2016 - 06:06

I found out what the problem was. I had a space in the filename which was giving the error.

$docx->enableCompatibilityMode();
$docx->createDocx('temp/Business Plan');
$docx->transformDocument('temp/Business Plan.docx', 'temp/Business Plan.pdf');

Once I changed the name to Business-Plan, it all worked fine.