Our Web API product ReportingCloud provides the reporting functionality of TX Text Control in an easy-to-use, platform independent REST web service. This sample shows how to use ReportingCloud to create dynamic HTML forms from MS Word compatible templates.

The following template consists of flat merge fields that should be merged with data entered in a web form.

Creating dynamic HTML forms using ReportingCloud

This sample uses the .NET wrapper for ReportingCloud that encapsulates all HTTP requests and provides compatible .NET classes to manage templates and to merge documents.

In the controller code, a new ReportingCloud object is created and the template is uploaded to the ReportingCloud template storage. Using the GetTemplateInfo method, merge field and merge block information of a template can be retrieved. This TemplateInfo object is returned to the view:

Loading...

In the view code, an HTML form element is created for each merge field in the template. The text of the field is used as the label text for each input element:

Loading...

The following screenshot shows the HTML form with the dynamically created input form elements for each merge field.

Creating dynamic HTML forms using ReportingCloud

In the controller Merge method, a Dictionary with the form data key pair values is created. This data is passed to the MergeDocument method as part of the MergeBody object. The MergeDocument method returns the created PDF document which is then returned to the browser:

Loading...

The returned PDF document shows the resulting document with the populated merge fields:

Creating dynamic HTML forms using ReportingCloud

With ReportingCloud, you can implement mail merge and reporting functionality into any application without installing any libraries on your servers or clients. Test this on your own and create a free trial account today.

Download the sample from GitHub and test it on your own.

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Requirements for This Sample

  • Visual Studio 2015 or better
  • ReportingCloud account (trial sufficient)
  • ReportingCloud .NET wrapper