PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

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

Open rajaafrajanjua opened this issue 1 year ago • 1 comments

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

  • [X] I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • [ ] I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)

rajaafrajanjua avatar Sep 06 '24 21:09 rajaafrajanjua

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

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

Progi1984 avatar Sep 07 '24 06:09 Progi1984