最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Pandoc is not rendering SVG images when converting from html to docx format - Stack Overflow

programmeradmin2浏览0评论

I amd using pandoc to convert a standalone html (with not external dependency), with all required css and js merged in html itself. HTML has few svg graphs generated via javascript library

The said html file, when opened in browser renders fine, but when converted to docx, svg images are missing from docx file.

mand used to convert, looks like

pandoc ./something.html -s -o test1.docx

What I suspect is that it is converting file before javascript could even render those images.

Appreciate help

I amd using pandoc to convert a standalone html (with not external dependency), with all required css and js merged in html itself. HTML has few svg graphs generated via javascript library

The said html file, when opened in browser renders fine, but when converted to docx, svg images are missing from docx file.

mand used to convert, looks like

pandoc ./something.html -s -o test1.docx

What I suspect is that it is converting file before javascript could even render those images.

Appreciate help

Share Improve this question asked Sep 17, 2018 at 14:16 ducktypedducktyped 4,5024 gold badges28 silver badges39 bronze badges 3
  • AFAIK, word just doesn't support embedded SVGs, so you'd have to convert them to png or something first. – mb21 Commented Sep 17, 2018 at 16:37
  • Word has supported SVG since ~ Word 2016. The Pandoc conversion, however, doesn't (AFAICT) support this. E.g., I can insert an SVG manually from within Word, but converting from Markdown to DOCX I get a broken image tag. Which is a pain. The pandoc-svg filter (gist.github./jeromerobert/3996eca3acd12e4c3d40) may work, but it converts it to a PNG, which doesn't help me much since I need high fidelity images for my usecase. – Dave Newton Commented Jan 26, 2019 at 18:48
  • 2 Just out of curiosity, have you figured this one out? I don't know enough Haskell to be able to update how this works (yet), and I have a ton of SVG images I need to insert into Word docs, and can't really convert to PNG because of the loss of clarity. – Dave Newton Commented Jan 26, 2019 at 19:23
Add a ment  | 

2 Answers 2

Reset to default 3

The docx needs a png fallback image, that it uses to show the image.

Pandoc doesn't create those fallback images, but they are aware of the issue. You can track the progress here:

https://github./jgm/pandoc/issues/4058

It should be included in the next release.

It is now implemented in 2.15

https://github./jgm/pandoc/releases/tag/2.15

发布评论

评论列表(0)

  1. 暂无评论