के लिए मेरे पीडीएफ लेखक के रूप में DomPDF बनाना मैं अपने अनुप्रयोग के लिए laravel का इस्तेमाल किया और dompdf में पाया जाता है:phpWord
../vendor/dompdf/dompdf
मैं क्या हासिल करने के लिए .pdf को मेरी .docx फ़ाइल (माइक्रोसॉफ्ट वर्ड) कन्वर्ट करने के लिए है चाहता था फ़ाइल। Docx फ़ाइल को phpWord द्वारा टेम्पलेट फ़ाइल लोड करके और मानों को प्रतिस्थापित करके उत्पन्न किया गया था।
यहाँ टुकड़ा है:
// 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);
उसके बाद, एक .docx फ़ाइल उत्पन्न हो जाएगा। मैं इसके पीडीएफ संस्करण भी बनाना चाहता था। तो मैं खोज और इस कोड स्निपेट पाया और मेरे कोड में कहा:
\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');
लेकिन मैं यह त्रुटि आई:
{"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}}
मैं कैसे PHPWord के लिए मेरे पीडीएफ लेखक के रूप में DomPDF होगा? मुझे कोई अन्य विकल्प नहीं मिल रहा है इसलिए मैं यहां पूछता हूं। मुझे आशा है आप मेरी मदद कर सकते हैं। धन्यवाद!
क्या आपने dompdf लाइब्रेरी के लिए एक पूर्ण पथ की कोशिश की है? – BrianS