php convert word pdf,Convert docx to pdf using PHP

I am currently generating multiple .docx files using PHPWord. I need to find a way to combine these docx files and save them as 1 pdf file. Is there a way that this can be done?

# Answer 1

4d350fd91e33782268f371d7edaa8a76.png

Open the generated docx with PHPDOCX http://www.phpdocx.com/

require_once 'phpdocx_pro/classes/TransformDoc.inc';

$docx = new TransformDoc();

$docx->setStrFile('document.docx');

$docx->generateXHTML();

$html = $docx->getStrXHTML();

Also, you can export the docx to PDF with

$docx->generatePDF();

Note this is not a free library

# Answer 2

You can look at http://www.phplivedocx.org/, they support docx and through the zend framework also the generation of pdfs.

# Answer 3

require_once dirname(__FILE__) .'/phpdocx/classes/TransformDoc.inc.php';

require_once dirname(__FILE__) .'/phpdocx/classes/CreateDocx.inc.php';

$docx = new TransformDoc();

$docx->setStrFile('document.docx');

$docx->generatePDF();

==> Its seems work but... where is the generated PDF ? How I can get PDF file ?

# Answer 4

/**

* return the pdf stream as a string returned from the function

*/

function output($debug = false) {

...

}

so just write the result of 'generatePDF()' to a file.

for example:

$content = $docx->generatePDF();

$myfile = fopen("newfile.pdf", "w");

fwrite($myfile, $content);

fclose($myfile);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值