INCLUDEPICTURE with DOCVARIABLE

We are unfortunately using INCLUDEPICTURE with a DOCVARIABLE to represent a datafield in our Word doc templates.

{ INCLUDEPICTURE "\\myfileserver\signaturefolder\{ DOCVARIABLE SIGNER_IMAGE }.jpg" \* MERGEFORMAT }

We need the ability to code a solution where we can set the DOCVARIABLE with a filename and allow the image to appear in the Word doc.

I am unable to locate this DOCVARIABLE node through code nor am I able to use the doc.Variables("SIGNER_IMAGE"). Please let me know if any work around exists which could prevent us from having to make modifications to our Word doc templates.

.Net Code

Private Sub UpdateDoc(ByVal stream As FileStream, ByVal newFilePath As String)
    Dim doc As New Document(stream)
    doc.Variables("SIGNER_IMAGE") = "MySignature"
    doc.UpdateFields()
    doc.Save(newFilePath)
End Sub

I’ve attached a sample Word doc template.

Thanks

Hi

Thanks for your inquiry. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved.
Maybe in your case, you can just insert images into the document during mail merge as described here:
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
Best regards,

Hello
Thanks for your interest in Aspose.Words. I’m working on the issue you have reported earlier. Let me explain little bit. Upon loading INCLUDEPICTURE field to the DOM (Document Object Model), Aspose.Words converts this field to shape, and that is why your problem occurs (there is no field inside shape). To fix this all that you need it is specify LoadOptions.PreserveIncludePictureField = true, in this case you will be able to replace DOCVARIABLE inside INCLUDEPICTURE field. Please see the following code:

LoadOptions loadOptions = new LoadOptions();
loadOptions.PreserveIncludePictureField = true;
Document doc = new Document("ImageTestTemplate.doc", loadOptions);
doc.Variables["SIGNER_IMAGE"] = "TestImage";
doc.UpdateFields();
doc.Save("out.doc");

Please let me know in case of any issues, I will be glad to help you.
Best regards,