PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.22k stars 2.68k forks source link

docx file not converting to pdf give error "DOMDocument::loadXML(): Namespace prefix m on oMath is not defined in Entity, line: 1" #2670

Open rajaafrajanjua opened 1 week ago

rajaafrajanjua commented 1 week ago

Describe the bug and add attachments

I want to convert docx file to pdf in laravel i got error "DOMDocument::loadXML(): Namespace prefix m on oMath is not defined in Entity, line: 1" my code is

Expected behavior

I just want want to convert the docx file to pdf.

Steps to reproduce

 private function convertToPDF($file){
    $pdfPath = tempnam(sys_get_temp_dir(), 'phpword_') . '.pdf';
    Settings::setPdfRendererName(Settings::PDF_RENDERER_DOMPDF);
    Settings::setPdfRendererPath(base_path('vendor/dompdf/dompdf'));

    $phpWord = IOFactory::load($file);
    $phpWordString = print_r($phpWord, true);
    Log::error("phpWord: {$phpWordString}");

    $xmlWriter = IOFactory::createWriter($phpWord, 'PDF');
    Log::error("xmlWriter: " . $xmlWriter);

    $xmlWriter->save($pdfPath);

    return $pdfPath;
}

PHPWord version(s) where the bug happened

1.2

PHP version(s) where the bug happened

8.2

Priority

Progi1984 commented 1 week ago

@tayyabjanjua Hi, Could you send the file for reproducing the issue ?

You Can crowdfund by following this link : https://docs.algora.io/bounties/workflow