问题
I am trying to figure out if there is a way to convert HTML to DOCX file using PHP.
HTML comes from wysiwyg editor (with inline styles) and I want to be able to create a DOCX file from it.
Looks like PHPWord can do just some basic inline styles and other libraries don't support inline styles at all.
Is there any way to achieve this?
回答1:
You can approach it like this:
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");
echo "";
echo "";
echo "
";echo "My first document";
echo "";
echo "";
?>
You can add inline styles like so:
echo "
Hello World!
";来源:https://stackoverflow.com/questions/43378219/php-html-to-docx