Hi Supports,
I used Aspose.Words 15.2.0 to generate PDF which worked well with IF condition. But After I migrated to Aspose.Words 17.4.0, the If condition can’t be merged correctly.
The following is the IF condition expression in my template,
{ IF { MERGEFIELD Account.Currency } = USD { MERGEFIELD Invoice.InvoiceNumber } { MERGEFIELD Account.Currency } }
To make the process more clear, I saved the result as DOC.
So with 15.2.0, I got the following result:
Invoice.InvoiceNumber, Account.Currency were not merged with 17.4.0.
Could you please have a look and fix this issue?
The following is the test code to reproduce this issue.
public class IFTest
{
public static void main(String[] args) throws Exception
{
Document doc = new Document("Account.Currency\_showMergeField\_unmatch\_template.doc");
doc.getMailMerge().execute(getDatasourceOne()); //Merge Invoice properties
doc.getMailMerge().execute(getDatasourceTwo()); //Merge Account properties
doc.save("IFCondition.doc", SaveFormat.DOC);
//doc.save"IFCondition.pdf", SaveFormat.PDF);
System.out.println("done.");
}
public static IMailMergeDataSource getDatasourceOne()
{
return new IMailMergeDataSource() {
boolean hasNext = true;
public String getTableName() throws Exception {
return "Invoice";
}
public boolean moveNext() throws Exception {
if (hasNext)
{
hasNext = !hasNext;
return true;
}
else
{
return false;
}
}
public boolean getValue(String paramString, Object[] paramArrayOfObject) throws Exception {
if (paramString.contains("Number"))
{
paramArrayOfObject[0] = "INV-000001";
}
else
{
return false;
}
return true;
}
public IMailMergeDataSource getChildDataSource(String paramString) throws Exception {
return null;
}
};
}
public static IMailMergeDataSource getDatasourceTwo()
{
return new IMailMergeDataSource() {
boolean hasNext = true;
public String getTableName() throws Exception {
return "Account";
}
public boolean moveNext() throws Exception {
if (hasNext)
{
hasNext = !hasNext;
return true;
}
else
{
return false;
}
}
public boolean getValue(String paramString, Object[] paramArrayOfObject) throws Exception {
if (paramString.contains("Currency"))
{
paramArrayOfObject[0] = "USD";
}
else
{
return false;
}
return true;
}
public IMailMergeDataSource getChildDataSource(String paramString) throws Exception {
return null;
}
};
}
}