有没有遇到过将文本或文档转换为PDF的PHP代码?
它必须按照原始txt或doc文件的格式进行,包括换行和新段落…
有没有遇到过将文本或文档转换为PDF的PHP代码?
它必须按照原始txt或doc文件的格式进行,包括换行和新段落…
使用phpLiveDocx可以将DOC格式文件转换为PDF格式文件:
$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);
请参考HTML_ToPDF。它同样适用于文本。
我已经很久没有接触 PHP 了,但如果你可以从中进行 Web 服务调用,那么可以尝试使用 this product。它提供了出色的转换保真度。它还支持其他格式,包括 Infopath、Excel、PowerPoint 等,以及水印支持。
请注意,我曾经参与过这个产品的开发,因此通常的免责声明适用。