use pandoc to embed images into a docx file that are in a HTML

浪尽此生 提交于 2019-12-07 02:34:14

问题


Is it possible to embed images into a docx file that are embedded in a HTML file?

I am trying and it's not working for me, and perhaps I am not adding some extra parameter when I am running pandoc.

pandoc -f html -t docx -o testdoc.docx image.html

Thank you very much!


回答1:


I managed to solved this by executing the following command:

pandoc -s file_name.html -o file_name.docx;

There are actually 2 important ponits that you need to consider:

  1. The quality of the output file is pretty much related to how pandoc interpret your HTML file, so that if the source was pretty complex then you wouldn't really expect a pretty good quality output, for instance the <hr/> tag is not recognized by pandoc, while the <p> tag is.
  2. The path of the image is not an HTTP path but instead it is a full desk path, meaning:

This is NO good:

<img src="http://www.example.com/images/img.jpg" />

And This is what pandoc can really read:

<img src="/var/www/example.com/images/img.jpg" />

HTH



来源:https://stackoverflow.com/questions/21527151/use-pandoc-to-embed-images-into-a-docx-file-that-are-in-a-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!