benim pdf yazar olarak DOMPDF yapma Benim app laravel kullanılan ve DOMPDF bulunur: Ben .pdf benim .docx dosyası (Microsoft Word) dönüştürmek için olduğunu ulaşmak istediği nedirphpWord
../vendor/dompdf/dompdf
dosya. Docx dosyası, şablon dosyasını yükleyerek ve değerleri değiştirerek phpWord tarafından oluşturuldu.
İşte pasajı var: Bundan sonra
// Get the absolute path of the template file
$wordTemplatePath = $this->getDocumentTemplatePath('resignation.docx');
// Load the template file
$document = $this->phpWord->loadTemplate($wordTemplatePath);
// This will be filled with data
$wordData = []
.... Process to fill the data .....
// Replace value to actual word document
$this->setTemplateValues($wordData, $document);
// Generate its filename
$file = $this->generateFileName('Retirement-Certificate.docx', $id);
// Fetch the absolute path to save the document
$filepath = $this->getSavePath($file);
// Save the word document
$document->saveAs($filepath);
, bir .docx dosya oluşturulur. Bunun da bir PDF sürümünü yapmak istedim. bu yüzden arama ve bu kod parçacığını buldu ve benim kodunda eklendi:
\PhpOffice\PhpWord\Settings::setPdfRendererPath('../vendor/dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setPdfRendererName('DOMPDF');
//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load($filepath);
//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save('result.pdf');
Ama bu hata var:
{"error":
{"type":"PhpOffice\\PhpWord\\Exception\\Exception","message":"PDF rendering library or library path has not been defined.",
"file":"C:\\xampp\\htdocs\\vagrant\\vendor\\phpoffice\\phpword\\src\\PhpWord\\Writer\\PDF.php",
"line":49}}
nasıl PHPWord benim pdf yazar olarak DOMPDF yapacak? Başka seçenekler bulamıyorum, bu yüzden burada soruyorum. Umarım bana yardım edebilirsin. Teşekkürler!
Dompdf kitaplığına mutlak bir yol denediniz mi? – BrianS