有人遇到过将文本或文档转换为 pdf 的 php 代码吗?
它必须遵循与原始 txt 或 doc 文件相同的格式,这意味着换行以及新段落...
可以使用以下命令将 DOC 转换为 PDFphpLiveDocx http://www.phplivedocx.org/2009/02/06/convert-doc-to-pdf-in-php/:
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setUsername('username')
->setPassword('password');
$phpLiveDocx->setLocalTemplate('document.doc');
// necessary as of LiveDocx 1.2
$phpLiveDocx->assign('dummyFieldName', 'dummyFieldValue');
$phpLiveDocx->createDocument();
$document = $phpLiveDocx->retrieveDocument('pdf');
file_put_contents('document.pdf', $document);
unset($phpLiveDocx);
对于文本到 PDF,您可以使用pdf 扩展名 http://php.net/manual/en/book.pdf.php是PHP。
您可以查看示例here http://www.php.net/manual/en/pdf.examples-basic.php.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)