Skip to content

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

Description

@rajaafrajanjua

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

  • 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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions