Aspose.Words for JasperReports provides a unique feature that allows inserting Microsoft Word fields to any point of the document. This can be used to insert page numbers that are dynamically updated as the document is being edited, TOC (table of contents), and many other things.
To enable field code recognition, use the following parameter:
JasperReports:
[Java]
import com.aspose.words.jasperreports.*;
AWDocExporter exporter = new AWDocExporter();
exporter.setParameter(AWExporterParameter.RECOGNIZE_FIELDS, true);
exporter.exportReport();
JasperServer:
[XML]
<bean id="aw_exportParameters" class="com.aspose.words.jasperreports.AWExportParametersBean">
<property name="recognizeFields" value="true"/>
</bean>
Once this parameter is set to true, the exporter treats any text enclosed in curve brackets ({}) as a field code and exports it appropriately. For example, the following text
Page { PAGE } of { NUMPAGES },
will contain two fields in the produced document, PAGE and NUMPAGES, whose are calculated to the current page number and the total number of pages in the document, respectively.
You can add any field arguments and switches supported by the field. For example, to insert a timestamp of document creation, insert the following text:
{ DOCPROPERTY CreateTime }