PHPOffice / PHPWord

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

DOCX to html #2158

Open ilya-yalovoy opened 3 years ago

ilya-yalovoy commented 3 years ago

Hello! I need a function that will pull all content from the docx by wrapping it in the appropriate html tags

f-ricci commented 2 years ago

If it helps, this is how I have implemented this

Laravel code

$wordDocument = IOFactory::load(Storage::disk(self::DISK)->path($this->file_path));

        $htmlWriter = IOFactory::createWriter($wordDocument, 'HTML');

        $pathinfo = pathinfo($this->file_path);

        $path = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '.html';

        $htmlWriter->save(
            Storage::disk(self::DISK)->path($path)
        );