Thanks to this excellent sample, I'm now familiar with the binding of values at runtime using docx4j from any well built xml file to a word template containing content controls. But I can't find a way to achieve the simular thing to inject a picture in my template.
I've tried to add a picture content control in my template using the Word developper ribbon, and bind it to a value in my xml input, value which is a 64bits encoded string of my picture. But when i'm performing the binding with docx4j, the generated doc file does not contains the picture, instead I get a weird result (see capture).
My binding method look like this :
// Process conditionals and repeats
OpenDoPEHandler odh = new OpenDoPEHandler(_document);
odh.preprocess();
OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(_document);
// Apply the bindings
// Convert hyperlinks, using this style
BindingHandler.setHyperlinkStyle("Hyperlink");
BindingHandler.applyBindings(_document);
// Strip content controls: you MUST do this
// if you are processing hyperlinks
RemovalHandler rh = new RemovalHandler();
rh.removeSDTs(_document, Quantifier.ALL);
The result after saving .docx result :
Am I missing something ? Can I find sample to do this properly somewhere ?
Thanks for your help ! CL
PS : I have created an equivalent post on docx4j forums : if a working solution is found there, i will report it here.