Free Support Forum -

If function in Demo


I am evaluating ASPOSE.WORD and was trying to do something similar to what has been done in the footer of the demo “SalesReportDemo.doc”. In the footer an “if” field is used as this: {if{numpages}>{page}“more”}.

Now I read in these forums that this is not supported, but I was curious what was being done in this example to make it work.



The key is that the word “supported” can mean different things in different contexts.

All fields, including IF and nested fields are supported if they are in the document and you just open the document, do something in it and save it.

You can also insert some fields using Aspose.Word into a document. You can insert most of the fields, however you cannot insert nested fields at the moments. Your example uses nested fields because NUMPAGES is inside IF. I mean you cannot create such expression programmatically in Aspose.Word yet.

Also, Aspose.Word does not evaluate fields so it cannot calculate the result of a field or an expression. This is what MS Word does. MS Word does not automatically recalculate fields when you open the document, you can get MS Word to recalculate fields if you select all and then press F9.

This brings us to another interesting issue, you might be able to insert a field into a document using Aspose.Word, but Aspose.Word does not calculate a result so the result will not be immediately visible in MS Word when you open the document.

The way it works in the demo, the field was created in MS Word when designing the report template. Aspose.Word just needs to preserve that nested field and its result while generating the report.