Reputation: 1
I have 2 files - one a template document in the form of a standard MS-Word docx format file, which is marked up with Content Control placeholders using the OpenDoPE add-in for MS-Word developed by Plutext. The second file is an XML file containing the data. Merging the two works perfectly using routines from DOCX4J. All good so far. The problem is that the XML file contains just the file pathname to where the image is located. So, after the merge, the Word document contains in place of the Content Control placeholders, a string indicating where the image is. How do I go about getting an image into the document in place of the image location strings.
One approach considered would be to replace the image path inside the XML data file with a base64 encoding of the image (not sure exactly how to do that, but the documentation for OpenDoPE suggest it should work). Another option seems to be to find the path strings in the already-merged Word document and then use something like the BinaryPartAbstractImage function from the DOCX4J library to insert the image in place. The problem with this seems to be that any search and replace operation in an OpenXML document appears to be fraught with difficulties.
Upvotes: 0
Views: 858
Reputation: 15878
At authoring time, put the base64 encoded image in some element in the sample XML file you use in conjunction with "friendly" OpenDoPE add-in.
Then, when you drag that element onto the document surface, the add-in should detect that it is an image, and add the corresponding tag to the content control.
If that is done, then at run-time, whatever base64 encoded image is in your run-time XML, will be used.
Upvotes: 0