Docx Recipe : Error while executing docx recipe. unsupported file type: undefined (file: undefined)
-
I am having an issue generating docx files through the jsreport api.
When developing in jsreport studio everything works fine and images are rendered properly and docx file gets generated as well:I am using base64 strings in the api payload following the documented way with images for the docxImage helper, by creating bookmarks and then adding hyperlinks to an image I add to the docx template. As you can see in the image, the base64 string is replacing the placeholder image I added to the docx template, so everything seems fine.
The issue happens when I deploy my changes and try to download the docx file through the api, then I get:
Error while executing docx recipe. unsupported file type: undefined (file: undefined)If I remove the images from the docx template and deploy the code again, it works fine, so there is something wrong with the images.
Do you know what may be causing this behavior ?
-
Could you please share the whole error with stack from the logs?
What jsreport version do you use?
-
"jsreport": "3.5.0"
"jsreport/office": "3.0.0"2022-06-20T16:11:59.292Z - warn: Error when processing render request 1 Error while executing docx recipe. unsupported file type: undefined (file: undefined) Error: Error while executing docx recipe. unsupported file type: undefined (file: undefined)
at module.exports (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-core/lib/shared/createError.js:10:13)
at WorkerReporter.createError (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-core/lib/shared/reporter.js:47:12)
at /home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-docx/lib/processDocx.js:93:20
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async module.exports (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-docx/lib/recipe.js:38:28)
at async invokeRender (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:95:5)
at async WorkerReporter._render (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-core/lib/worker/render/render.js:147:7)
at async /home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-core/lib/worker/reporter.js:177:19
at async Domain.<anonymous> (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/advanced-workers/lib/workerHandler.js:141:19)
caused by: TypeError: unsupported file type: undefined (file: undefined)
at lookup (/home/ubuntu/aba-matrix-jsreport/node_modules/image-size/lib/index.js:34:9)
at module.exports (/home/ubuntu/aba-matrix-jsreport/node_modules/image-size/lib/index.js:96:12)
at processImage (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-docx/lib/postprocess/processImage.js:208:28)
at /home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-docx/lib/postprocess/drawingObject.js:60:33
at doReplace (/home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:139:21)
at /home/ubuntu/aba-matrix-jsreport/node_modules/@jsreport/jsreport-docx/lib/recursiveStringReplaceAsync.js:145:16
at Semaphore.<anonymous> (/home/ubuntu/aba-matrix-jsreport/node_modules/semaphore-async-await/dist/Semaphore.js:206:46)
at step (/home/ubuntu/aba-matrix-jsreport/node_modules/semaphore-async-await/dist/Semaphore.js:32:23)
at Object.next (/home/ubuntu/aba-matrix-jsreport/node_modules/semaphore-async-await/dist/Semaphore.js:13:53)
at fulfilled (/home/ubuntu/aba-matrix-jsreport/node_modules/semaphore-async-await/dist/Semaphore.js:4:58) rootId=ayuzwgxnuxlanqh, id=ayuzwgxnuxlanqh
2022-06-20T16:11:59.293Z - warn: Rendering request 1 finished with error in 1907 ms rootId=ayuzwgxnuxlanqh, id=ayuzwgxnuxlanqh
2022-06-20T16:11:59.300Z - warn: Error during processing request at http://internal-report-lb-qa.elb.amazonaws.com/api/report
-
@jan_blaha, please see logs and versions above any thoughts ? Thank you in advance.
-
Thank you, the error actually comes from an external library that is trying to calculate width/height of your image, but fails with this useless error.
So your template looks like this?
https://playground.jsreport.net/w/anon/djDV3qYr
If you run it through the API you get that error?