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?


  • administrators

    it tooks us a bit of time but the good news is that we now support set width, height, usePlaceholderSize as properties of the docxImage helper. this change is part of the jsreport-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 accept cm 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.


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.