我想将以前的word / doc文件转换为pdf,但是当我运行此代码 die 块实际上正在运行时,我遇到了一些错误,但在此之上,我将声明TCPDF和tcpdf值>
<?php
require_once 'vendor/autoload.php';
$objWriter=\PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$phpword=$objWriter->load('edited.docx');
$rendererName=\PhpOffice\PhpWord\Settings::PDF_RENDERER_TCPDF;
$rendererLibrary='tcpdf';
$rendererLibraryPath=''.$rendererLibrary;
if(!\PhpOffice\PhpWord\Settings::setPdfRenderer(
$rendererName,
$rendererLibraryPath
)){
die(
"NOTICE:Please set the $rendererName and $rendererLibraryPath values".
"<br>".
"at the top of this Script as Appropriate for your Directory Structure"
);
}
$rendererLibraryPath=''.$rendererLibrary;
$objWriter=\PhpOffice\PhpWord\IOFactory::createReader($phpword,'PDF');
$objWriter->saveAs("test.pdf");