Forum


Replies: 12   Views: 4505
Problems with ms word 2010
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 howard@falconandfoxglove.co.uk  · 29-03-2014 - 21:13

I am thinking of buying the Pro+ version but don't have the confidence to spend the money!



I have been trying for 3 days with the Trial Pro download to get templates working but as soon as I create a php programme with



$docx->addTemplate('../../Documents/AST-TDS.docx');



$docx->createDocxAndDownload('../docx/AST-TDS');



the downloaded file just will not load into Word and an error message saying 'Illegal qualified name character in word/document.xml appears.



I have tried everything - downloading the file directly from the server etc but the file created when a template file is added is just corrupt.



Anybody got any ideas? If I can get this bit working it will do everything I want and I'll buy the Pro+ version.



Howard Baker - UK



 


Posted by howard@falconandfoxglove.co.uk  · 30-03-2014 - 08:52

I forgot to mention it does not work with the examples supplied for template development - i.e. it's not just the name of my tempale file.



Check.php confirms all is working correctly with all itmes OK


Posted by jorgelj  · 31-03-2014 - 09:29

Hello,



Please post your server info and try running one the of the included examples using the CLI mode.



Regards.


Posted by howard@falconandfoxglove.co.uk  · 31-03-2014 - 09:57

The Server is at a web hosting company (Fasthosts) here in the UK and I don't have access to the CLI interface.



The path to the examples is http://selectivelicensingburnley.co.uk/examples/easy/Template.php



All the examples etc are there. I have modified template to CreateDocxAndDownload so you can access the output. The same result occurs if I ftp to the site and download the file myself from the examples/docx directory.



Template_text.php example is also available for direct download. All others examples are stored on the server but create Docx files in the examples/docx directory.



many thanks


Posted by jorgelj  · 31-03-2014 - 10:40

Hello,



As you don't have access to the CLI mode we recommend you to test the examples on your own server/machine.



And about your server check the webserver logs to find any issue or error.



Regards.


Posted by howard@falconandfoxglove.co.uk  · 31-03-2014 - 18:57

Hi,



I am now trying to run the example script on localhost and get the following error message



Exception: Error while opening the Base Template: please, check the path in C:\wamp\www\classes\AutoLoader.inc(2) : eval()'d code on line 2



Can this help you to help me?


Posted by jorgelj  · 01-04-2014 - 09:19

Hello,



It seems you are missing some files like the base template or you need to install some PHP dependencies like zip or XML support.



Regards.


Posted by howard@falconandfoxglove.co.uk  · 01-04-2014 - 09:28

hi,



I have expanded Autoloader.inc as follows:-



<?php



class AutoLoader { public static function load() {

     spl_autoload_register(array('AutoLoader', 'autoloadGenericClasses'));

     spl_autoload_register(array('AutoLoader', 'autoloadPhpdocx'));

     spl_autoload_register(array('AutoLoader', 'autoloadLog4php'));

     spl_autoload_register(array('AutoLoader', 'autoloadZetaComponents'));

     spl_autoload_register(array('AutoLoader', 'autoloadTcpdf'));

     spl_autoload_register(array('AutoLoader', 'autoloadPdf'));

     spl_autoload_register(array('AutoLoader', 'autoloadDompdf'));

     spl_autoload_register(array('AutoLoader', 'autoloadMht'));

 

    require_once dirname(__FILE__) . '/Helpers.inc';

}

 

public static function autoloadDompdf($className) {

     $pathDompdf = dirname(__FILE__) . '/../pdf/dompdf_config.inc.php';

     if (file_exists($pathDompdf)) {

         require_once $pathDompdf;

     }

}

    

public static function autoloadGenericClasses($className) {

    $pathPhpdocx = dirname(__FILE__) . '/' . $className . '.inc';

    

    if (file_exists($pathPhpdocx)) {

        $arrayClassesEnc = array( 'CreateDocx', 'AutoLoader', 'Phpdocx_config', 'CreateElement', 'Helpers', );

    

    if (in_array($className, $arrayClassesEnc)) {

        require_once $pathPhpdocx;

        }

    else

        {

        eval (gzinflate(base64_decode(file_get_contents($pathPhpdocx))));

        }

    }

}



public static function autoloadLog4php($className) {

    $pathLogphp = dirname(__FILE__) . '/../lib/log4php/' . $className . '.php';

    if (file_exists($pathLogphp)) {

        require_once $pathLogphp;

        }

}

 

public static function autoloadMht($className) {

    $pathMht = dirname(__FILE__) . '/../lib/' . $className . '.php';

    if (file_exists($pathMht)) {

        require_once $pathMht;

        }

}



public static function autoloadPdf($className) {

    $pathPDF = dirname(__FILE__) . '/pdf/' . $className . '.inc';

    if (file_exists($pathPDF)) {

        require_once $pathPDF;

        }

    $pathTCPDF = dirname(__FILE__) . '/../pdf/tcpdf/tcpdf.php';

    

    if (file_exists($pathTCPDF)) {

    require_once $pathTCPDF;

    }

    

    $pathFPDI = dirname(__FILE__) . '/../lib/fpdi/fpdi.php';

    

    if (file_exists($pathFPDI)) {

        require_once $pathFPDI;

        }

}

 

public static function autoloadPhpdocx($className) {

    $pathPhpdocx = dirname(__FILE__) . '/docx/' . $className . '.inc';

    if (file_exists($pathPhpdocx)) {

        require_once $pathPhpdocx;

        }

}

 

public static function autoloadTcpdf($className) {

    $pathTcpdf = dirname(__FILE__) . '/../pdf/class.tcpdf.php';

    if (file_exists($pathTcpdf)) { require_once $pathTcpdf;

    }

}

 

public static function autoloadZetaComponents($className) {

    

    if (preg_match('/^ezcBase/', $className)) { $ezcBaseClasses = require dirname(__FILE__) . '/../lib/zetacomponents/Base/src/base_autoload.php';

    

    if (array_key_exists($className, $ezcBaseClasses)){

        $classPath = $ezcBaseClasses[$className];

        $classPathFix = this.zetaComponentsFileName($classPath);

        $pathZetaComp = dirname(__FILE__) . '/../lib/zetacomponents/' . $classPathFix;

        

        if (file_exists($pathZetaComp)) {

            require_once $pathZetaComp;

            }

        }

    }

        

    if (preg_match('/^ezcGraph/', $className)) {

            $ezcGraphClasses = require dirname(__FILE__) . '/../lib/zetacomponents/Graph/src/graph_autoload.php';

            if (array_key_exists($className, $ezcGraphClasses)){

                $classPath = $ezcGraphClasses[$className];

                $classPathFix = this.zetaComponentsFileName($classPath);

                $pathZetaComp = dirname(__FILE__) . '/../lib/zetacomponents/' . $classPathFix;

                

            if (file_exists($pathZetaComp)) {

                    require_once $pathZetaComp;

                    }

                }

        }

}



private function zetaComponentsFileName($file) {

    list( $first, $second, $third ) = explode( '/', $file, 3 );

    if ( !empty($third) ) {

        return $file = $first . "/src/" . $second . '/' . $third;

        }

    else {

        list( $first, $second ) = explode( '/', $file, 2 );

        return $file = $first . "/src/" . $second;

        }

    }



The error is now clearly identifed as at the line shown in bold above.



The file you suggest may be missing are definitely there. I really feel I am close to the answer but as neither I nor my hosting company have had experience of PHPDOCX I am stuck. PLEASE HELP!


Posted by jorgelj  · 01-04-2014 - 09:48

Hello,



This error:



Exception: Error while opening the Base Template: please, check the path in C:\wamp\www\classes\AutoLoader.inc(2) : eval()'d code on line 2



shows when the base template has not read access or you need to install ZIP or XML support on your PHP. Not due to the eval or gzinflate.



Regards.


Posted by howard@falconandfoxglove.co.uk  · 05-04-2014 - 10:39

Hi,



I have managed to track down the problem to the phpdocxbasetemplate.docx which appears (or claims to be corrupt) in Office Word 2010.



What is in this template and how can I recreate it using my version of Word?


Posted by howard@falconandfoxglove.co.uk  · 05-04-2014 - 11:38

Word can identify that One or more footnotes are missing or corrupt.



These are :-



Endnotes 1



Footnotes 1



No idea what these are but when I save the file it is still corrupt?



Footnotes 2


Posted by jorgelj  · 07-04-2014 - 09:20

Hello,



The base template is generated with Word on Windows but you can create your own template and overwrite the default one.



Regards.