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.
I would welcome any opinions and pointers to working code samples.
Aucun commentaire:
Enregistrer un commentaire