问题
I'm generating a markdown document using my Rails 4.2 app which includes images that are on the same server (in the public
folder).
Using pandoc (pandoc-ruby 1.0.0), I want to convert the document into various formats, especially HTML (to preview it in the browser) and DOCX (to download it).
The preview in the browser works perfect. But when converting to DOCX, the images aren't included. I guess this is due to multiple requests to referenced images while pandoc is generating the document.
I have already experimented with setting allow_concurrency
to true
, but this didn't solve the problem. Also, it happens on both the development and the production environment (while in development, it takes a long time, and in production it doesn't - maybe due to some differences in timeout limits?).
I have already found a way to solve my problem by not referencing the images using an URL, but by embedding it as base64 string into the document. But this for sure can't be the solution of choice, as it tends to bloat up the HTML document a lot. Also, on production, I already get RuntimeError (Stack space overflow: current size 8388608 bytes)
from pretty small embedded images. So I have to find a real solution.
回答1:
Reference the images by file path instead of url if they are on the same server.
来源:https://stackoverflow.com/questions/34955656/generating-a-docx-file-using-pandoc-images-missing-due-to-multiple-requests