Hello,
Hi,
Yes, you can do that. Check attached template as an example. Image dimensions set in the template will not be disturbed in output file. Do no forget to call Document.updateFields() after executing mail merge.
Best Regards,
Hi,
Tanks for your help. I’m using this template (template-avatar.docx).
Can I use stream instead of image path file?
What about java code, it’s the same like :
document.getMailMerge().execute(fields, values);
document.save(dstStream, SaveFormat.DOCX);
Or there is somthing specific to INCLUDEPICTURE?
When we use Document.updateFields() ?
Thanks.
Hi,
Yes, Java code is same. You can find this code at http://www.aspose.com/docs/display/wordsjava/How+to++Execute+Simple+Mail+Merge
As far as loading image from stream is concerned, you should use merge field in that case. If you want to use INCLUDEPICTURE in any case, then you will have to pass file name as this is a limitation imposed by MS Word.
Best Regards,
Hi,
LoadOptions options = new LoadOptions();
options.setLoadFormat(LoadFormat.DOCX);
options.setPreserveIncludePictureField(true);Document doc = new Document(getMyDir() + “template-avatar.docx”, options);
doc.getMailMerge().execute(new String[]{“AVATAR”}, new Object[]{“D:\\temp\\aspose.words.jpg”});
doc.save(getMyDir() + “15.7.0.docx”);
Hello,
As include picture can’t use byte[] (word limitation), I think to stock picture in a shared directory and reference the full path of each image. (Also I must replace “” by “\\” :s )
Thanks for your Help.
Hi,