Zend LiveDocx - 无法从磁盘读取本地模板


Zend LiveDocx - Cannot read local template from disk

我正在尝试在我的 zend 框架项目中创建一个 word 文档,但它不起作用!

这是我的操作代码:

public function createwordAction(){
    $this->_helper->layout->disableLayout();
    $this->_helper->viewRenderer->setNoRender();
    require_once 'Zend/Service/LiveDocx/MailMerge.php';
    try{
        $mailMerge = new Zend_Service_LiveDocx_MailMerge();
        $mailMerge->setUsername('***********')
                  ->setPassword('******');
        $mailMerge->setLocalTemplate('/license-agreement-template.docx');
        $mailMerge->assign('software', 'Magic Graphical Compression Suite v1.9')
            ->assign('licensee', 'Henry Döner-Meyer')
            ->assign('company',  'Co-Operation')
            ->assign('date',     'January 11, 2010')
            ->assign('time',     'January 11, 2010')
            ->assign('city',     'Berlin')
            ->assign('country',  'Germany');
        $mailMerge->createDocument();
        $document = $mailMerge->retrieveDocument('pdf');
        file_put_contents('document.pdf', $document);
    }
    catch (Exception $e) {
        die ('Application error: ' . $e->getMessage());
    }
}

我的模板位于我的项目的根目录(公用文件夹)中。模板是从本教程下载的,我没有编辑或打开它......

catch 异常显示此错误:

应用程序错误:无法从磁盘读取本地模板。

我还尝试将模板的路径更改为:

$templatepath = APPLICATION_PATH + "../public/license-agreement-template.docx";
$mailMerge->setLocalTemplate($templatepath);

但同样的结果...

然后我尝试使用 chmod 更改文件权限,如下所示:

chmod("/license-agreement-template.docx",0755);

然后我得到这个错误:

警告: chmod(): 没有这样的文件或目录

有人遇到过同样的问题吗?或者有人可以帮助我吗?

我从未听说过LiveDocx,但这是我所做的:

  • 已搜索LiveDocx的源代码以查找您的特定错误:

来了

引发异常if (!is_readable($filename))

您的

文件可能存在一些正确的问题(或您的文件名不正确) 更改 PHP 上传的文件的权限