Populate Template with Data
In this article you will learn that how to populate Mail Merge or mustache template with data.
This API represents a controller for executing the mail merge.
The following is a description of the most important parameters:
Merge with regions or not. False by default.
Flag ‘withRegions’ can be omitted, in this case, a simple mail merge will be executed. If the flag is present and value is ‘true’ - mail merge with regions will be executed.
|mailMergeDataFile||If mailMergeDataFile parameter exists, the data is taken from the server path (the parameter must contain the full path to the server file). However, if the mailMergeDataFile parameter is omitted, the data is expected in the requested content.|
If the cleanup parameter is omitted, cleanup options will be None.
|useWholeParagraphAsRegion||Specifies a value indicating whether paragraphs with TableStart or TableEnd field should be fully included in the mail merge region or particular range between TableStart and TableEnd fields. The default value is true.|
The cleanup options parameter can contain a list of values from below, separated by “,":
|None||Without any cleanup.|
|EmptyParagraphs||Specifies whether paragraphs that contained mail merge fields with no data should be removed from the document.|
|UnusedRegions||Specifies whether unused mail merge regions should be removed from the document.|
|UnusedFields||Specifies whether unused merge fields should be removed from the document.|
|ContainingFields||Specifies whether fields that contain merge fields (for example, IFs) should be removed from the document if the nested merge fields are removed.|
|RemoveTitleRow||Removes title row of the table if this table doesn’t contain any rows except title row. It does not remove title rows in nested tables.|
|RemoveTitleRowInInnerTables||Enable “RemoveTitleRow " for nested tables.|
|RemoveStaticFields||Specifies whether static fields should be removed from the document. Static fields are fields, which results remain the same upon any document change. Fields, which do not store their results in a document and are calculated on the fly (like Aspose.Words.Fields.FieldType.FieldListNum, Aspose.Words.Fields.FieldType.FieldSymbol, etc.) are not considered to be static.|
Both JSON and XML data formats are supported. Choosing the appropriate data format makes a difference in flexibility, scalability and performance speed of your application. XML and JSON have much in common with their own strengths and drawbacks. You need to determine which one is the most preferred for your purposes.
Usage examples with cURL and Postman
You can carry out REST API interactions using
Postman. Please read these instructions to receive a personal
JWT_TOKEN for authorization.
Case 1: MailMerge Template
Case 2: Mustache Template
Aspose.Words Cloud SDK Family
Using SDK is the best way to speed up the development. Our Cloud SDKs take care of low-level details and let you focus on your primary tasks.
Please check out the GitHub repository for a complete list of Aspose.Words SDKs.
Usage examples in Python, Java, C#, etc.
The following code samples show how to interact with the REST API using almost any mainstream programming language.