One of TX Text Control's strengths is the ability to generate dynamic contracts and agreements of all types. With pixel-perfect rendering, 100% content control, and text floating, paragraphs and dynamic sections can be perfectly aligned. Other reporting approaches, such as band reporting, do not offer such granularity.
In this article, we will guide you through various features of the design aspects for the pixel-perfect, dynamic contract generated from JSON data.
The template will provide the following features:
- Section-based headers and footers
- Table of contents
- Dynamic, conditional sections
- Signature blocks
- Dynamic footnotes
JSON Data Source
TX Text Control's reporting engine merges data from various data sources into a template. The data source can be a database, a JSON object, or any other data source. In this example, we are using a JSON object to merge data into the template.
The following JSON object represents a contract with placeholders for the dynamic data:
[ | |
{ | |
"contract_date": "2020-01-01", | |
"provider": { | |
"name": "Service Provider LLC", | |
"address": "123 Main St, IL 62701 Springfield", | |
"contact": { | |
"name": "John Doe", | |
"title": "CEO" | |
} | |
}, | |
"client": { | |
"name": "Client LLC", | |
"address": "456 Elm St, IL 62701 Springfield", | |
"contact": { | |
"name": "Jane Doe", | |
"title": "CFO" | |
} | |
}, | |
"service": [ | |
{ | |
"type": "Service 1", | |
"detail": "Service 1 details", | |
"start_date": "2020-01-01", | |
"end_date": "2020-12-31", | |
"payment": { | |
"amount": 1000, | |
"terms": "net 30", | |
"frequency": "monthly", | |
"due_days": "30 days", | |
"late_fee": 50 | |
} | |
} | |
], | |
"expense_days": "30 days", | |
"termination": { | |
"notice_days": 30, | |
"cause_days": 30 | |
}, | |
"law": "Illinois", | |
"arbitration_body": "AAA", | |
"section_intellectual_property": { | |
"ownership": "Client", | |
"license": "exclusive" | |
}, | |
"section_indemnification" : {} | |
} | |
] |
Template Design
The template contains merge fields that are replaced with data from the JSON object. The following screenshot shows the first page of the contract template with merge fields:
This template page uses several different features, including section-based headers and footers, a table of contents, and merge fields that access data from different hierarchy levels. For example, the provider name is accessed from the JSON structure by the property name of the provider object using the dot notation provider.name.
The following screenshot shows the second page of the contract template with some other interesting features:
Conditional Blocks
The sections highlighted in red are conditional merge blocks. In the JSON data, you will find an entry for section_intellectual_property, which is also the block name of the first highlighted block.
"section_intellectual_property": { | |
"ownership": "Client", | |
"license": "exclusive" | |
}, |
The properties for the ownership and license fields come from this object. But the interesting part is the data itself. If you remove the section_intellectual_property element from the JSON data during the merge process, the entire section is not rendered.
The same is true for the section_indemnification merge block, which also contains a footnote (red circle). The following results are returned when these elements are missing from the passed JSON data.
As a result, you can see that the entire Intelligent Property and Indemnification sections have been removed. And with that, the included footnotes are removed as well. With floating text, all numbered list items are re-counted and the text flows properly to fit the page.
In the following animated screenshot, you can see both merge processes, one with the conditional blocks and one without the conditional blocks.
Signature Blocks
The last page contains the signature blocks with signature fields for capturing electronic signatures in the PDF or when using the Document Viewer.
When signed, these signature fields can be digitally signed using a certificate to create an encrypted and secure Adobe PDF document.
Using MailMerge
TX Text Control's Mail
╰ DocumentServer Namespace
╰ MailMerge Class
The MailMerge class is a .NET component that can be used to effortlessly merge template documents with database content in .NET projects, such as ASP.NET web applications, web services or Windows services. class is used to merge the JSON data into the template. The following code snippet shows how to merge the JSON data into the template and save the resulting document as a PDF file:
using TXTextControl.DocumentServer; | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) | |
{ | |
tx.Create(); | |
tx.Load("acme_agreement.tx", TXTextControl.StreamType.InternalUnicodeFormat); | |
MailMerge mailMerge= new MailMerge() { TextComponent = tx }; | |
string json = System.IO.File.ReadAllText("data.json"); | |
mailMerge.MergeJsonData(json, true); | |
foreach (TXTextControl.TableOfContents toc in tx.TablesOfContents) | |
{ | |
toc.Update(); | |
} | |
tx.Save("results.pdf", TXTextControl.StreamType.AdobePDF); | |
} |
Download
Download
You can download the template and the sample JSON data from the link below and use it for your own testing purposes.
Conclusion
TX Text Control's reporting engine is a powerful tool for creating dynamic contracts and agreements. With the ability to merge data from multiple data sources into one template, you can create pixel-perfect documents with dynamic content. Conditional blocks, floating text, and dynamic footnotes are just a few of the features that make TX Text Control the perfect tool for creating contracts and agreements.
The template design is flexible and can be customized to meet your specific needs. Signature blocks can be used to capture electronic signatures and create secure PDF documents.