40496

Generating a docx file using Pandoc: images missing! Due to multiple requests?

Question:

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.

Answer1:

Reference the images by file path instead of url if they are on the same server.

Recommend

  • Read BuiltInDocumentProperties/CustomDocumentProperties alway null with Word 2010?
  • How get paragraph FontName with Docx dll?
  • Word Add-in - How to read custom document property
  • Word 2007 VBA: ActiveDocument.CustomXMLParts
  • Displaying iOS iAds only to supported countries
  • Why does Redshift need to do a full table scan to find the max value of the DIST/SORT key?
  • android duplicate provider authority on apps that don't have provider
  • unrecognized selector isPitched called
  • Zend framework 2 : Add different authentication adapter for two different modules
  • Python adding lots of things to PATH. How do I stop?
  • include dlls in visual studio c++ 2008
  • Alamofire and Reachability.swift not working on xCode8-beta5
  • JavaScript IE rotation transform maths
  • C# - Most efficient way to iterate through multiple arrays/list
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • netsh acl setting (need alternative method - registry settings?)
  • how to set variables in a php include file?
  • what makes a request a new request in asp.net C#
  • Possible to “watch” both HAML and SASS at the same time?
  • Implementing “partial void” in VB
  • saving file generated by TCPDF
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • What's the purpose of QString?
  • Eloquent paginate function in Slim 3 project using twig
  • System.InvalidCastException: Specified cast is not valid
  • Content-Length header not returned from Pylons response
  • Python urlparse: small issue
  • Read a local file using javascript
  • Recording logins for password protected directories
  • Apache 2.4 and php-fpm does not trigger apache http basic auth for php pages
  • How to recover from a Spring Social ExpiredAuthorizationException
  • ILMerge & Keep Assembly Name
  • Can I make an Android app that runs a web view in Chrome 39?
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • SetUp method failed while running tests from teamcity
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • -fvisibility=hidden not passed by compiler for Debug builds
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`