我不知道为什么我的程序找不到它的路径
它不断显示
Fatal error: Uncaught exception 'PhpOffice\PhpWord\Exception\Exception' with message 'PDF rendering library or library path has not been defined.'
in C:\xampp\htdocs\TESTproject\vendor\phpoffice\phpword\src\PhpWord\Writer\PDF.php:50 Stack trace:
#0 C:\xampp\htdocs\TESTproject\vendor\phpoffice\phpword\src\PhpWord\IOFactory.php(44): PhpOffice\PhpWord\Writer\PDF->__construct(Object(PhpOffice\PhpWord\PhpWord))
#1 C:\xampp\htdocs\TESTproject\123.php(42): PhpOffice\PhpWord\IOFactory::createWriter(Object(PhpOffice\PhpWord\PhpWord), 'PDF')
#2 {main} thrown in C:\xampp\htdocs\TESTproject\vendor\phpoffice\phpword\src\PhpWord\Writer\PDF.php on line 50
和第一个$ t返回空值
我在testpdf.php中设置了以下路径:
1 <?php
2
3 require_once 'vendor/autoload.php';
4 // Creating the new document...
5 $phpWord = new \PhpOffice\PhpWord\PhpWord();
6
7 /* Note: any element you append to a document must reside inside of a Section. */
8
9 // Adding an empty Section to the document...
10$section = $phpWord->addSection();
11// Adding Text element with font customized using named font style...
12$fontStyleName = 'oneUserDefinedStyle';
13$phpWord->addFontStyle(
14 $fontStyleName, array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
15);
16$section->addText(
17 '"The greatest accomplishment is not in never falling, '
18 . 'but in rising again after you fall." '
19 . '(Vince Lombardi)', $fontStyleName
20);
21
22// Adding Text element with font customized using explicitly created font style object...
23$fontStyle = new \PhpOffice\PhpWord\Style\Font();
24$fontStyle->setBold(true);
25$fontStyle->setName('Tahoma');
26$fontStyle->setSize(13);
27$myTextElement = $section->addText('"Believe you can and you\'re halfway there." (Theodor Roosevelt)');
28$myTextElement->setFontStyle($fontStyle);
29
30// Saving the document as HTML file...
31$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
32$objWriter->save('helloWorld.html');
33
34$domPdfPath = 'C:\xampp\htdocs\TESTproject\vendor\dompdf\dompdf';
35$t = \PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
36echo $t . ' first<br>';
37
38$t = \PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
39echo $t . ' second<br>';
40
41$temp = \PhpOffice\PhpWord\IOFactory::load('helloWorld.docx');
42$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($temp, 'PDF');
43$xmlWriter->save('helloWorld.pdf');
44?>
我将phpword.ini.dist更改为phpword.ini并设置绝对路径为&lt; pdfRendererPath =&#34; C:\ xampp \ htdocs \ TESTproject \ vendor \ dompdf \ dompdf&# 34;&#39;
当我将路径更改为&#39; vendor / dompdf / dompdf&#39;时,显示了
Fatal error: Uncaught exception 'PhpOffice\PhpWord\Exception\Exception' with
message 'Unable to load PDF Rendering library'
BTW,\vendor\phpoffice\phpword\src\PhpWord\Writer\PDF
中的任何内容都有用吗?我还没有感动任何东西