【发布时间】:2014-10-08 14:16:58
【问题描述】:
我想加载一个 ODF 文件作为模板,对文档进行变量(字符串)替换,然后输出一个带有替换字符串的新 ODF 文件。 phpdocx 可以做到这一点还是我应该寻找其他工具?
这是我目前拥有的:
$docx = new CreateDocx();
$docx->setTemplateSymbol('^');
$docx->enableCompatibilityMode();
$docx->addTemplate($source);
$docVarArray = $docx->getTemplateVariables();
// TODO phpdocx variable replacement here.
$docx->createDocx($destination);
...在$docx->addTemplate($source) 期间因错误而死:
PHP message: PHP Fatal error: Call to a member function appendChild() on a non-object in /path/libs/phpdocx/classes/CreateTemplate.inc on line 433
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /path/script.php:0
PHP message: PHP 2. CreateDocx->addTemplate() /path/script.php:40
PHP message: PHP 3. CreateTemplate->openTemplate() /path/libs/phpdocx/classes/CreateDocx.inc:4119
PHP message: PHP 4. CreateTemplate::addRelationship() /path/libs/phpdocx/classes/CreateTemplate.inc:711" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /script.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php
我认为这是失败的,因为 phpdocx 需要一个 MSWord 文档。
谢谢!
【问题讨论】: