Using HTML Canvas in docx recipe
My team already has template to generate report using docx recipe. It's working fine until I've been assigned to a task where a client asked to include thermal images for their report.
We have functions to decode raw thermal images from backend as an array buffer. We successfully render thermal images in our web app using HTML Canvas API,
CanvasRenderingContext2D.createImageData(). And now I am wondering how to render the decoded thermal images to docx recipe. Can I use HTML canvas inside docx recipe? So I can use
createImageData()like I did in web app.
This is list of packages we use
Note: I am new to jsreport
Not sure if the Word supports canvas images natively.
Anyway, the recipe now supports just png and jpeg images.
What you need to do is convert the canvas to the png.
This can be done on your client-side, or by implementing a custom jsreport templating engine helper.
Here you can find an example of how the image can be resized using a custom helper
Your solution will be similar, you just need to use an extra package that can convert canvas into png. Like this one
Thanks for your suggestion, It's done using node-canvas.