0

I need to convert word file (Docx) to PDF using Lavevel. But when successfully exporting to PDF, there is a font error. I use PhpWord and dom-pdf. Here is my code:

   public function ConvertWordToPDF()
    {
        $domPdfPath = base_path('vendor/dompdf/dompdf');
        \PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
        \PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
        $Content = \PhpOffice\PhpWord\IOFactory::load(storage_path('app/attachments/f576b52163749f78dee912.06905290.docx'));
        $PDFWriter = \PhpOffice\PhpWord\IOFactory::createWriter($Content, 'PDF');
        $PDFWriter->save(storage_path('hung176.pdf'));
        echo 'File has been successfully converted';
    }

enter image description here

Can anyone help me, thank you.

I tried but can't find a fix.

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141

0 Answers0