Forum


Replies: 1   Views: 2640
The file is saved in the browser only
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 JSC_ESC_Vostok  · 04-12-2018 - 15:04

Hi, i have a problem with phpdocx on Windows Server 2016

PHP  = 7.2

Laravel 5.7, Class install correctly.

License = Premium

When this script is executed,

        $docx = new \Phpdocx\Create\CreateDocx();
        $docx->enableCompatibilityMode();
        $text = 'Lorem ipsum dolor ...';
        $docx->addText($text, $paramsText);
        $docx->createDocx('example_text');
        $docx->transformDocument('example_text.docx', 'example_text.pdf');

file is rendered to browser (*.docx, not *.pdf).

When i using:

        $docx->createDocx('D:\example_text');
        $docx->transformDocument('D:\example_text.docx', 'D:\example_text.pdf');

I getting the same (render D_example_text.docx to browser).

ALWAYS render to browser.

How fix it?

I want open template, fill data and save file as PDF without saving *.docx in file system. It's possible?

 

Posted by admin  · 04-12-2018 - 16:14

Hello,

The default behavior of phpdocx is saving the DOCX into the filesystem but not downloading it (https://www.phpdocx.com/documentation/cookbook/download-generated-docx). Using a Premium license you can enable the stream mode in the config/phpdocxconfig.ini file or through a static variable (CreateDocx::$streamMode) to return the DOCX as a stream an avoid creating the DOCX in the fs. On  https://www.phpdocx.com/documentation/cookbook/improve-phpdocx-performance you can read about more information about the stream mode.

About the conversion to PDF, the DOCX must exist in the filesystem to be able to transform it into another document format.

Regards.