0

我正在使用 PDFWord 生成动态文档。.docx 和 .html 生成完美,但我无法生成 .pdf (我已尝试过 DomPDF 和 TCPDF)

这是我的代码示例:

// Saving the document as OOXML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('documents/RFP_for_'.str_replace(' ', '_', $info[org_name]).'.docx');

// Saving the document as HTML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
$objWriter->save('documents/RFP_for_'.$info[org_name].'.html');

// Saving the document as PDF file...
\PhpOffice\PhpWord\Settings::setPdfRendererPath('vendor/tcpdf');
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');

$template->saveAs('documents/'.$file_name.'.docx');
$temp = \PhpOffice\PhpWord\IOFactory::load('documents/'.$file_name.'.docx');
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($temp , 'PDF');
$xmlWriter->save('documents/'.$file_name.'.pdf', TRUE);
4

0 回答 0