Forum


Replies: 3   Views: 4289
Blank or corrupted word documents on new server
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 OGTadmin  · 17-10-2012 - 20:19


I have been trying to setup the 2.5.1 Pro version on a Windows Server with IIS 6.0. When running the examples, they either produce blank Word documents or corrupted Word documents. My custom code produces a blank Word document. (Note that the free version of PHODOCX seems to run fine on this server.)

From the forums, it appears this can occur when there are permission problems with PHP or the Network Services. As a developer, I am not an expert on these configurations, but hopefully somebody can provide more specific information to help me solve the problem, or allow me to communicate the required changes to our server administrator.

I ran check.php here is the output:

Your PHP version is 5.3.17 => OK
Your Zip extension version is 1.11.0 => OK
Your XSL extension version is 0.1 => OK
Your Tidy extension version is 2.0 => OK

Here is the php error log output when running the List.php example:

17-Oct-2012 19:43:01 UTC] PHP Notice: Trying to get property of non-object in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 1061
[17-Oct-2012 19:43:01 UTC] PHP Notice: Undefined variable: newName in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 5884
[17-Oct-2012 19:43:01 UTC] PHP Warning: scandir(C:\WINDOWS\TEMP/1507f0a4594f55,C:\WINDOWS\TEMP/1507f0a4594f55): Access is denied. (code: 5) in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 5885
[17-Oct-2012 19:43:01 UTC] PHP Warning: scandir(C:\WINDOWS\TEMP/1507f0a4594f55): failed to open dir: No such file or directory in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 5885
[17-Oct-2012 19:43:01 UTC] PHP Warning: scandir(): (errno 2): No such file or directory in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 5885
[17-Oct-2012 19:43:01 UTC] PHP Warning: Invalid argument supplied for foreach() in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 5886
[17-Oct-2012 19:43:01 UTC] PHP Warning: copy(../docx/example_list.docx): failed to open stream: No such file or directory in E:\Inetpub\wwwroot\XGT\webappsdev\ogt\cop\phpdocx\v2.5.1\classes\CreateDocx.inc on line 4162






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

Hello,

You're getting an access deny when writting to temp folder. You can return a custom temp directory in line 6156 (method getTempDir) or set it in construct method (second parameter).

Regards.

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

Thanks. Based on this help, I am posting my solution for anyone else who may encounter the same Temp directory access rights issue.

A modified List.php example is shown below. I initially had problems with this solution because I only used the relative template path and not the relative path to the actual template [u]document file[/u] in the constructor.

My full solution also involved creating a docx and Temp directory under the examples directory:

v2.5.1/examples/docx
v2.5.1/examples/Temp

The new Word document is created in the docx directory. Note that I later moved the Temp directory to a better location for our server. Also note that your custom code files will likely have different relative paths than the example projects.

[code]

<?php

/**
* Insert an unordered list into a Word document.
*
* @category Phpdocx
* @package examples
* @subpackage easy
* @copyright Copyright (c) 2009-2011 Narcea Producciones Multimedia S.L.
* (http://www.2mdc.com)
* @license http://www.phpdocx.com/wp-content/themes/lightword/pro_license.php
* @version 1.8
* @link http://www.phpdocx.com
* @since File available since Release 1.8
*/
require_once '../../classes/CreateDocx.inc';

$docx = new CreateDocx("../../templates/phpdocxBaseTemplate.docx", "../Temp");

$valuesList = array(
'Line 1',
'Line 2',
'Line 3',
'Line 4',
'Line 5'
);

$paramsList = array(
'val' => 1
);

$docx->addList($valuesList, $paramsList);

$docx->createDocx('../docx/example_list');


[/code]