我目前正在使用PHPWord生成多个.docx文件。 我需要找到一种方法将这些docx文件合并并保存为1个pdf文件。 是否有一种方法可以实现这个功能?
我目前正在使用PHPWord生成多个.docx文件。 我需要找到一种方法将这些docx文件合并并保存为1个pdf文件。 是否有一种方法可以实现这个功能?
使用PHPDOCX打开生成的docx文件 http://www.phpdocx.com/
require_once 'phpdocx_pro/classes/TransformDoc.inc';
$docx = new TransformDoc();
$docx->setStrFile('document.docx');
$docx->generateXHTML();
$html = $docx->getStrXHTML();
此外,您可以使用以下方式将docx导出为PDF:
$docx->generatePDF();
请注意,这不是一个免费的库。
/**
* return the pdf stream as a string returned from the function
*/
function output($debug = false) {
...
}
只需将“generatePDF()”的结果写入文件即可。
例如:
$content = $docx->generatePDF();
$myfile = fopen("newfile.pdf", "w");
fwrite($myfile, $content);
fclose($myfile);