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

    0_1753860108246_upload-c5e05d47-38cd-4496-8215-a50da18e2c1d

    0_1753860229159_upload-0a451b7b-e8de-4023-9277-75eb6b0236d2

    0_1753860260858_upload-da6e0822-a314-4777-9b96-a05ea2bf8ced

    I need help please someone know.

    thanks in advance.


  • administrators

    hi! it is not enough to put the handlebars in the document, you have to follow some specific steps.

    from the docs:

    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.

    0_1754558674996_upload-aa72a7bb-aecf-4baa-9a2a-58f618f69140


  • administrators

    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 your logoBase64 to some invalid url like https://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.

    0_1754634540551_upload-7f558c9c-4deb-48c1-a239-1876e689cb00


  • administrators

    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.


Log in to reply
 

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