Dynamic DOCX report using xdocreport and template to add an image


Aniket Gedam

2024-06-19 10:40:09


How to add image in docx file dynamically ? 

1. Create a template where the bookmarks will be added for the image. 

2. Use this template for reference : click here

3. From this template, use their image markers / copy image as follows and put it in custom template that we are preparing. 

Custom doc: 

 

 

4. Make sure the bookmark names are there and these will be used in the code to identify which image will go where.

 

The Sample code for the template given in the point 2 can be obtained here :  https://github.com/opensagres/xdocreport.samples/blob/master/samples/fr.opensagres.xdocreport.samples.docxandfreemarker/src/fr/opensagres/xdocreport/samples/docxandfreemarker/DocxProjectWithFreemarkerAndImage.java