Open Windd01 opened 3 years ago
@Windd01
Try this working example. .docx
to .pdf
conversion
$docxPath = 'abc.docx';
$pdfPath = 'abc.pdf';
$domPdfPath = realpath('/vendor/dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord = \PhpOffice\PhpWord\IOFactory::load($docxPath);
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save($pdfPath);
@JBavaliya Thank you I did the same as you But I get an error it's a font error Hope you help
Im trying to convert .docx file to .pdf with code below :
$domPdfPath = base_path('vendor/dompdf/dompdf');
Settings::setPdfRendererPath($domPdfPath);
Settings::setPdfRendererName('DomPDF');
$Content = IOFactory::load('test.docx');
$Content->setDefaultFontName('Roboto');
$PDFWriter = IOFactory::createWriter($Content, 'PDF');
$PDFWriter->save('test.pdf');
But mathtype and vietnamese in .docx cannot converted. Mathtype throwed something like : <Object: word/embeddings/oleObject1.bin>