Free Support Forum - aspose.com

Nested Merge Field (MERGEFIELD) in INCLUDEPICTURE | Mail Merge on Template Word Document using C# .NET

I use INCLUDEPICTURE with MERGEFIELDS in a template.

Example:
{ INCLUDEPICTURE “W: ​\Pictures\{ MERGEFIELD P_NACHNAME }.{ MERGEFIELD P_VORNAME }.png” }
In WORD the MERGEFIELDS are correctly replaced and the picture is displayed.
Result: { INCLUDEPICTURE “W:​​\Pictures\Baum.Horst.png” }

Problem:
In Aspose.Words (version 20.4) the MERGEFIELDS are not recognized and are not replaced.
They do not appear in the document.Range.Fields - Collection, nor are they handled in the MergeFieldHandler.

@Niebelschutz,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document
  • The image file
  • Aspose.Words 20.5 generated output DOCX file showing the undesired behavior
  • Your expected DOCX file showing the desired output. You can create this document by using MS Word.
  • Please also create a standalone simple console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL/JAR files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you more information. Thanks for your cooperation.

20200507 - Includepicture.zip (32.7 KB)

@Niebelschutz,

We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-20395. We will further look into the details of this problem and will keep you updated on the status of the linked issue. Sorry for the inconvenience.

Have you already looked at the problem?
Our customer urgently needs a solution to his problem.

@Niebelschutz,

I am afraid, your issue (WORDSNET-20395) is currently pending for analysis and is in the queue. We will keep you posted here on any further updates.

We apologize for any inconvenience.

@Niebelschutz,

Regarding WORDSNET-20395, it is to update you that we have completed the work on this issue and concluded to close this issue with “Not a Bug” status. Please see the following analysis details.

The INCLUDEPICTURE field is converted to a shape by default when loading a document. So, please set the PreserveIncludePictureField option to true:

var loadOptions = new LoadOptions();
loadOptions.PreserveIncludePictureField = true;
var document = new Document(fileName, loadOptions);

Hope, this helps.

If I set the PreserveIncludePictureField option, it works as in MS Word.
Thanks a lot.

@Niebelschutz,

Thanks for your feedback. In case you have further inquiries or may need help in future, please let us know.