This sample demonstrates how to dynamically generate loan application documents using the Syncfusion .NET Word Library (DocIO). The application loads a Word template, performs mail merge operations with loan applicant data, and exports the generated documents to PDF format.
This is a practical example of using DocIO for automated document generation in financial services, HR, and business process automation scenarios.
The dynamic-application-document-generation sample showcases:
- Loading and manipulating existing Word document templates (DOCX format)
- Performing mail merge operations with structured data sources
- Working with complex document templates containing multiple merge fields
- Converting Word documents to PDF format programmatically
- Handling financial and legal document generation workflows
- Batch processing of documents with different data sets
This application generates Loan Sanction Letters for a banking system. It demonstrates:
- Loading a pre-designed Word template (
Template.docx) containing merge fields - Creating a
Templateclass to model loan applicant and collateral information - Populating merge fields with real applicant data (name, address, loan amount, EMI, ROI, etc.)
- Automatically generating multiple documents from a single template
- Converting the generated documents to PDF for distribution and archival
The application generates documents for three loan applicants:
- Rajesh Kumar - Home Construction Loan (₹25,50,000) at 8.75% ROI
- Arun Sharma - Business Expansion Loan (₹51,00,000) at 10.25% ROI
- Sneha Patil - Vehicle Purchase Loan (₹12,25,000) at 9.50% ROI
- Syncfusion DocIO - Word document processing and manipulation
- .NET 8.0 - Platform and runtime
- DocIORenderer - Document rendering engine for PDF conversion
- Syncfusion PDF - PDF document creation and manipulation
- Loading Word documents with
FormatType.Automaticfor format detection - Using
MailMergeDataTablefor structured data binding - Configuring mail merge options (
RemoveEmptyParagraphs,StartAtNewPage) - Executing mail merge operations with
ExecuteGroup() - Converting Word documents to PDF with
DocIORenderer - Enabling complex script detection (
AutoDetectComplexScript)
dynamic-application-document-generation/
├── Program.cs # Main application logic with mail merge and PDF conversion
├── Data/
│ └── Template.docx # Word template with merge fields
├── Output/
│ └── Output.pdf # Generated PDF output
└── dynamic-application-document-generation.csproj
-
Prepare the Template:
- Ensure
Template.docxexists in theDatafolder - The template should contain merge fields matching the
Templateclass properties - Common merge fields:
{{lanNumber}},{{applicants1Name}},{{sanctionedAmount}}, etc.
- Ensure
-
Run the Application:
dotnet run
-
Output:
- The application will generate a merged PDF document saved as
Output/Output.pdf - The PDF will contain documents for all applicants in the sample data
- The application will generate a merged PDF document saved as
The Template class contains the following merge field mappings:
Loan Information:
lanNumber- Loan Application NumberversionNumber- Document versionschemeType- Type of loan (Home Loan, Business Loan, Vehicle Loan)sanctionedAmount- Sanctioned loan amountROI- Rate of InteresttenureMonths- Loan tenure in monthsappFinancialEmi- Monthly EMI amount
Applicant Information:
applicants1Title,applicants1Name- Primary applicant detailsapplicants1FathersName- Applicant's father nameapplicants1SpouseName- Applicant's spouse nameapplicants1CustomerAddresses- Residential address
Collateral Information:
appCollaterl1Collateral_Address- Property addressappCollaterl1BuiltupArea- Property built-up areaappCollaterl1natureOfProperty- Property typeappCollaterl1PINCode- Property postal code
Other Details:
executionDate,busisnessDate- Document datesexecutionPlace,sourcingBranch- Location informationltvValue- Loan-to-Value ratioemiStartDate- First EMI datewebsiteLink- Bank website URL
- Microsoft Word 97-2003
- Microsoft Word 2007
- Microsoft Word 2010
- Microsoft Word 2013
- Microsoft Word 2016
- Microsoft Word 2019
- Microsoft 365
- Creates, reads, and edits popular text file formats like DOC, DOT, DOCM, DOTM, DOCX, DOTX, HTML, RTF, TXT, Markdownand XML (WordML).
- Converts Word documents also to PDF, Image, and ODT files.
- Download this project to a location in your disk.
- Open the solution file using Visual Studio.
- Rebuild the solution to install the required NuGet packages.
- Run the application.
- Product page: Syncfusion® Word Framework
- Documentation: Syncfusion® Word library
- Online demo: Syncfusion® Word library - Online demos
- Blog: Syncfusion® Word library - Blog
- Knowledge Base: Syncfusion® Word library - Knowledge Base
- Ebooks: Syncfusion® Word library - Ebooks
- FAQ: Syncfusion® Word library - FAQ
- For any other queries, reach our Syncfusion® support team or post the queries through the community forums.
- Request new feature through Syncfusion® feedback portal.
This is a commercial product and requires a paid license for possession or use. Syncfusion's licensed software, including this component, is subject to the terms and conditions of Syncfusion's EULA. You can purchase a licnense here or start a free 30-day trial here.
Founded in 2001 and headquartered in Research Triangle Park, N.C., Syncfusion® has more than 29,000 customers and more than 1 million users, including large financial institutions, Fortune 500 companies, and global IT consultancies.
Today, we provide 1700+ components and frameworks for web (Blazor, ASP.NET Core, ASP.NET MVC, ASP.NET WebForms, JavaScript, Angular, React, Vue, and Flutter), mobile (Xamarin, Flutter, UWP, and JavaScript, .NET MAUI) and desktop development (WinForms, WPF, WinUI, Flutter, UWP, and .NET MAUI) a. We provide ready-to-deploy enterprise software for dashboards, reports, data integration, and big data processing. Many customers have saved millions in licensing fees by deploying our software.