Forum


Replies: 5   Views: 3443
Using templates
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 smaubian  · 27-10-2011 - 17:12

Hello,

I'm starting using phpdocx today and was not able to have it working using a template.
What i did is creating a very simple template.docx file (few words) and then try to load it to a phpdocx element :

[code]
require_once(LIBPATH."/phpdoc/classes/CreateDocx.inc"); // where LIBPATH can be "../folder/"

$template="./template.docx";
if(!file_exists($template)) {
$this->setError("class createDOC render : unable to load DOC template : $template. exiting",true);
}

$t=new CreateDocx();
$t->addTemplate($template);
$t->createDocxAndDownload('bouh.docx');
[/code]


And each time the result is an "empty" docx file. I do not understand what happen. Version 2.4 (pro), i have added my key to the 'code' file and am on the correct domain www/myphpdocxdomain.com/mypath/myFile.php



any help / suggestion ?.



Posted by admin  · 11-04-2013 - 12:13

Hello,

Please try included examples, if they run ok there're a problem related to the template otherwise check your server config.

Regards.

Posted by smaubian  · 11-04-2013 - 12:13

So the issue is that i'm using a user (www-data) to run apache and when i use the createDocxAndDownload() it's just not working. If i create a folder (with full access to user www-data) and use createDocx command it works.

I think this is related to the usage of tmp folders because i can see your files in /tmp created by user www-data but when i'm requested to download the file this is an empty one.

I will investigate later as i do not plan to create the file on the server , i just need a passthrough

Posted by smaubian  · 11-04-2013 - 12:13

Just looked at the source this morning,


You are always using the system defined temp Dir.

Just as a matter of improvement adding in the settings the ability to force the tmp folder path (or a method : setTempDir() ) can be usefull as in some cases the system temp dir is not the best place to use.

Posted by admin  · 11-04-2013 - 12:13

Hello,

We aim to add that new setting.

Regards.