How to convert html to word using php?

前端 未结 3 2036
栀梦
栀梦 2020-12-15 12:00

I am trying to convert HTML to MS WORD document (.doc/.docx) with PHP script. With the available scripts from internet I am able to convert the text of HTM

相关标签:
3条回答
  • 2020-12-15 12:28

    I would highly recommend PHPdocx as it does exactly what your asking for, but at a cost. I purchased it sometime ago and use it frequently.

    require_once 'pathToPHPDocX/classes/CreateDocx.inc';
    $docx = new CreateDocx();
    $html='http://www.2mdc.com/PHPDOCX/simpleHTML_Image.html';
    $docx->embedHTML($html, array('isFile' => true, 'downloadImages' => true));
    $docx->createDocx('simpleHTML');
    

    http://www.phpdocx.com/documentation/introduction/html-to-word-PHP

    0 讨论(0)
  • 2020-12-15 12:31

    I am currently working through something similar and have gone with

    • PHPWord

    Huge amount of information on the site to get you started and you can style each element how you would like.

    Images can be added simply with: $section->addImage($src, [$style]);

    I would take a look. Its a bit more involved than what you are currently using, but allows you to do what you need.

    0 讨论(0)
  • 2020-12-15 12:42

    just keep following code in top of the page need to convert:

    <? header("Content-Type: application/vnd.ms-word");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("content-disposition: attachment;filename=Report.doc");
    ?>
    
    0 讨论(0)
提交回复
热议问题