Home  >  Q&A  >  body text

java - html如何转成doc[x]?(要包含带外链的图片!)

RT,如何能使html转成doc文件,尤其是兼容图片!

目前测试用JODConverter + OpenOffice,生成的doc文件中无法显示图片!
原因在官方邮件列表中提到是因为html中图片是外链。

尝试使用 DATA URL SCHEME 把图片数据存入html文件中,也无法正常显示图片!

请问,html2doc大家都是怎么实现的?解决方案不限于java~

迷茫迷茫2766 days ago398

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:34:01

    I provide a solution that I used before for reference only.
    The customer wants to export the form into an Excel file for him to download. At first, I wondered if I was afraid of this. My Python master has a package for operating excel. But when I looked at the xlrd document, it was so troublesome to generate a table, so I didn’t want to do it anymore. I think my table does not need to draw a complicated header, so I directly output the table into an html file using HTML Table, but specify the file name as xxx.xls in the Content-Disposition of the returned HTTP. In this way, it will be opened directly as an EXCEL file on Windows, and Excel will automatically convert the table in HTML into its table.

    You can output html directly, but specify the file name as xxx.docx in the header of the downloaded file. The result format may not look good, but this can be adjusted slowly. As for pictures, you can try the MHTML format supported by IE, which can embed pictures. I remember that Word should be able to recognize pictures in MHTML format.

    reply
    0
  • Cancelreply