Hello,
We are implementing a Word report using the docx
recipe and encountered issues when inserting multiple images into the report.
Issue Description
To include images, we use the docxImage
helper, providing the src
as a base64 data URL. In the beforeRender
script, images are prefetched to handle authentication properly and then passed to docxImage
.
However, this approach leads to high memory consumption, often resulting in an Out of Memory (OOM) error when processing larger images or multiple images at once.
At the same time, when images are provided as direct URLs - allowing docxImage
to handle the loading - everything works fine.
Reproduction
We have created a minimal example to reproduce the issue: https://playground.jsreport.net/w/anon/CVpIkxye (See README for details).
Possible Cause & Suggested Solution
From what I see, axios
is responsible for loading images inside the docxImage
helper, specifically in this line:
https://github.com/jsreport/jsreport/blob/master/packages/jsreport-docx/lib/imageUtils.js#L32
We would like to know if there’s a way to provide custom options to this axios request. In our case, we need to:
I initially tried setting axios
defaults within the report script, but I suspect that docxImage
and report scripts run in separate contexts, so this approach didn't work.
Request for Support
Is there a recommended way to handle this? Any advice on working around the OOM issue or configuring axios
inside docxImage
would be greatly appreciated.
Thanks in advance!