How to set image size when using docxImage?
-
I using the docxImage to display a picture, but I found the size was the picture size even I set the size in the wrod document. How to set image size when using docxImage?
-
Currently, the recipe always uses the size of the dynamic image provided through templating engine. Not the placeholder's size.
I submitted the feature request to add more options.
https://github.com/jsreport/jsreport/issues/647
-
@jan_blaha , thanks for your replay, when will fix this issuse?
another, is possible support url instead of the image base64 string when I using the docImage?
-
it tooks us a bit of time but the good news is that we now support set
width
,height
,usePlaceholderSize
as properties of thedocxImage
helper. this change is part of thejsreport-docx
2.4.0
(you can install that version of jsreport-docx if you need this right now in your jsreport installation)usage:
{{docxImage src=src usePlaceholderSize=true}}
-> this will take the dimensions of the placeholder image defined on the docx and will set the new image to those dimensions
{{docxImage src=src width="150px" height="100px"}}
-> this will set the image to 150px of width and 100px height, widht and height also acceptcm
values (ex: width="8cm")docs about this will be updated soon..
is possible support url instead of the image base64 string when I using the docImage?
this was not considered for this update, however it may come later. the good thing is that you can replicate this feature with jsreport scripts, you fetch remote image there in
beforeRender
hook and then set the base64 string to some data property (req.data.src
) and the docx conversion flow will work normally.
-
Thanks @bjrmatos , I will try the new method to set the image size.