docxImage doesn't work for me
-
Hello good,
I am trying to use docxImage in a word to be able to generate different images in a word depending on the base64 that is passed to it, since the images will vary and I am not able to display it when I execute the jsreport, I get the base64 in the text.
I created a word just with this to see if it was something in my word but there is no way, I'll give you screenshots
I need help please someone know.
thanks in advance.
-
hi! it is not enough to put the handlebars in the document, you have to follow some specific steps.
Prepare image placeholder using word - place any image to the desired position and format it to your needs.
Select image, select Word tab "Insert", click on "Bookmark and create one
Right click image and click "Hyperlink"
Click bookmark and select previously created bookmark
Click ScreenTip still on the "Insert Hyperlink" modal.
Fill the docxImage helper call {{docxImage src=myDataURIForImage}}
Hit ok and close the hyperlink dialog. Now if you hower the image you should see the docxImage helper call
Run the template with myDataURIForImage prop in the input data and you should see the image replaced in the output.here is an example
-
It works for me now, thanks :)
-
And I have another question: how to display the default image in the docx if the logo doesn't have a value?
How can I do this? Because I pass the variable as null (I also tried empty or without passing the variable) and the report isn't generated. I get an error.
I have this in my hyperlink image: {{docxImage src=logoBase64 usePlaceholderSize=true failurePlaceholderAction="preserve" }} but it doesn't work. I just want it to generate the report without errors and with the image already included in the report.
Best regards and thanks in advance.
-
hi! if you want to preserve the image of the docx template you need to force an error, the
failurePlaceholderAction
will do its job when detecting that there is an error loading the image. to force the error you can set yourlogoBase64
to some invalid url likehttps://error
.it looks inconvenient to do it this way, but maybe in the future we will allow to pass the null value.
-
Hi, I set the value as you told me, "https://error," and I'm still getting an error, but now it's a different one. In my docx, I still have {{docxImage src=logoBase64 usePlaceholderSize=true failurePlaceholderAction="preserve" }}
Do you know why this might be?
Thank you very much in advance.
-
it works for me on latest jsreport (4.10.0), what version are you using? if using a different version, ensure you are using latest jsreport.