使用 Yii 创建 PDF 或 Word 文档?
您好,我正在使用 Yii 构建一个应用程序,现在它将生成报告。我的客户想要在生成报告后对其进行编辑。我认为最好的选择是创建一个 Word 文档,以便我的客户能够编辑它,但我找不到使用 Yii Framework 创建 Word 文档的信息或扩展。
我还见过但尚未测试几个 PDF 扩展,例如 DOMPDF、tcpdf 和 Zend_PDF。但如果我生成 PDF 报告,那么我的客户将如何编辑该文件?
伙计们,我需要有关如何解决此要求的建议。生成 Word 或 PDF 文档?哪个解决方案开发速度最快?
Hello I'm building an application with Yii that will now generate reports. My client wants to edit the reports after these are generated. I think the best option is creating a Word document so my client will be able to edit it, but I can't find information or extensions to create Word documents with Yii Framework.
I've also seen but not test yet a couple of PDF extensions such as DOMPDF, tcpdf and Zend_PDF. But if I generate a PDF report, then, how is my client going to edit this file?
Guys I need recommendations on how to tackle this requirement. Generate Word or PDF documents? Which will be the fastest to develop solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新1:
目前我已经可以使用 PDF 了。我是这样做的:首先,我从其 站点 下载 TCPdf 并在 Yii 中打开它作为第三方库。然后:
无论如何,我希望能够生成一个Word文档,因为要求表示报告将在生成后由用户编辑。
更新2:
对于 Word 文档的报告生成这就是我正在做的。
UPDATE 1:
At the moment I got PDFs working. This is how I did it: First I downloaded TCPdf from its site and open it in Yii as a 3rd-party library. Then:
Anyway I want to be able to generate a word document as the requirement says the report is going to be edited by the user after generation.
UPDATE 2:
For the Word document's report generation this is what I am doing.
Yii 中提供了生成 PDF 文档的扩展。 tcpdf (http://www.yiiframework.com/extension/tcpdf/) 例如..
查看这篇文章,了解可用于 PDF 和 Excel 的选项的综合综述
http://www.yiiframework.com/wiki/74/
但是,如果您需要要创建 Word 文档,那么您可以尝试以下
在 Yii 中编写扩展来生成 Word 文档(请参阅此链接,其中显示了如何在 PHP/Linux 中执行此操作 - 在 Linux 中使用 PHP 创建 Word 文档)
Extensions are available in Yii to generate PDF documents. tcpdf (http://www.yiiframework.com/extension/tcpdf/) for example..
Check this article on a general roundup of options available for PDF and Excel
http://www.yiiframework.com/wiki/74/
However, if you need to create word documents, then you can try the following
Write a extension in Yii to generate word document (please see this link which shows how to do it in PHP/Linux - Create Word Document using PHP in Linux)
要创建Word文档,您可以使用phpword库
要使用,请将库提取到文件夹 protected\extensions\PHPWord
解压后在此文件夹中,您将拥有文件夹: Examples, PHPWord 和一个文件: PHPWord.php 。
在您的控制器/代码中,您需要像本示例中那样调用:
To create word document you can use phpword library
And to use, extract the library to folder protected\extensions\PHPWord
In this folder after extract you will have folders: Examples, PHPWord and one file: PHPWord.php .
In your controller/code you need to call like in this example: