Why waste time with manual paperwork? Switch to digital forms and streamline your process today!
Digital PDF forms are important because they enable users to complete tasks faster and easier. Unlike paper forms, you can fill them on any device and avoid the hassle of scanning or mailing them. Digital PDF forms are quicker for the person filling them out and the businesses receiving them.
MESCIUS offers the Document Solutions for Pdf (DsPdf) API for programmatically creating and working with PDF documents. It allows developers to automate the generation of PDF content, including interactive forms, whether you're building a form from scratch or modifying an existing PDF.
In this blog, we'll create a digital loan request PDF form using DsPdf, automatically filling it with user-provided data from the website. This ensures accuracy and offers a faster, more efficient loan application process. Let's walk through the steps to create the loan submission form using DsPdf:
Ready to Get Started? Download Document Solutions for PDF Today!
Design Web Form for User Input
Let's build a web form in an ASP.NET Core MVC application to collect essential information from users, such as their personal details, employment information, and loan request specifics. This data will be captured when users submit the form by clicking the button. Below is the HTML code for creating the user form:
The user form created using the above code is shown below:

We’ve created a LoanApplicationModel class to manage and store the form inputs. When the user clicks the button, the model captures the data, and the controller processes it for further actions. Below is the code of the Model and Controller to fetch the filled information:
Generate Digital PDF Form Using DsPdf
In this step, we'll explore how to create a fillable PDF form, often called an AcroForm. The form includes fields like text boxes, checkboxes, buttons, and more, which users can fill out manually or through code. DsPdf provides various properties and methods in the AcroForm class to add, change, remove, and format these form fields. Refer to our documentation to learn more about form fields.
Below is the C# code to create the digital Loan request pdf form:
var doc = new GcPdfDocument();
var page = doc.NewPage();
var g = page.Graphics;
var tf = new TextFormat();
tf.Font = StandardFonts.Times;
tf.FontSize = 14;
var ip = new PointF(72, 72);
float fldOffset = 72 * 2;
float fldHeight = tf.FontSize * 1.2f;
float dY = 32;
g.DrawImage(Image.FromFile("bank-bca-logo-vector-format-cdr-eps-svg-pdf-png-0.png"), new RectangleF(150, 10, 200, 90), new ImageScale());
g.DrawString("Loan Application Form", new TextFormat()
{
Font = StandardFonts.Times,
FontSize = 20,
FontBold = true,
ForeColor = Color.DarkBlue
}, new PointF(150, 110));
ip.Y += 80;
g.DrawString("Full Name:", tf, ip);
var fldFullNameText = new TextField();
fldFullNameText.Widget.Page = page;
fldFullNameText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldFullNameText.Widget.DefaultAppearance.Font = tf.Font;
fldFullNameText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldFullNameText);
ip.Y += dY;
g.DrawString("Date of Birth:", tf, ip);
var fldDOBText = new TextField();
fldDOBText.Widget.Page = page;
fldDOBText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldDOBText.Widget.DefaultAppearance.Font = tf.Font;
fldDOBText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldDOBText);
ip.Y += dY;
g.DrawString("Residential Address:", tf, ip);
var fldAddressText = new TextField();
fldAddressText.Widget.Page = page;
fldAddressText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldAddressText.Widget.DefaultAppearance.Font = tf.Font;
fldAddressText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldAddressText);
ip.Y += dY;
g.DrawString("Email Address:", tf, ip);
var fldEmailText = new TextField();
fldEmailText.Widget.Page = page;
fldEmailText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldEmailText.Widget.DefaultAppearance.Font = tf.Font;
fldEmailText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldEmailText);
ip.Y += dY;
g.DrawString("Phone Number:", tf, ip);
var fldPhoneNumberText = new TextField();
fldPhoneNumberText.Widget.Page = page;
fldPhoneNumberText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldPhoneNumberText.Widget.DefaultAppearance.Font = tf.Font;
fldPhoneNumberText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldPhoneNumberText);
ip.Y += dY;
g.DrawString("Employment Status:", tf, ip);
var fldEmploymentStatusComboBox = new ComboBoxField();
fldEmploymentStatusComboBox.Editable = true;
fldEmploymentStatusComboBox.Items.Add(new ChoiceFieldItem("Employed"));
fldEmploymentStatusComboBox.Items.Add(new ChoiceFieldItem("Self-Employed"));
fldEmploymentStatusComboBox.Items.Add(new ChoiceFieldItem("Unemployed"));
fldEmploymentStatusComboBox.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldEmploymentStatusComboBox.Widget.Page = page;
doc.AcroForm.Fields.Add(fldEmploymentStatusComboBox);
ip.Y += dY;
g.DrawString("Occupation/Job Title:", tf, ip);
var fldJobTitleText = new TextField();
fldJobTitleText.Widget.Page = page;
fldJobTitleText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldJobTitleText.Widget.DefaultAppearance.Font = tf.Font;
fldJobTitleText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldJobTitleText);
ip.Y += dY;
g.DrawString("Employer's Name:", tf, ip);
var fldEmployerNameText = new TextField();
fldEmployerNameText.Widget.Page = page;
fldEmployerNameText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldEmployerNameText.Widget.DefaultAppearance.Font = tf.Font;
fldEmployerNameText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldEmployerNameText);
ip.Y += dY;
g.DrawString("Years of Employment:", tf, ip);
var fldYearsOfEmploymentText = new TextField();
fldYearsOfEmploymentText.Widget.Page = page;
fldYearsOfEmploymentText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldYearsOfEmploymentText.Widget.DefaultAppearance.Font = tf.Font;
fldYearsOfEmploymentText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldYearsOfEmploymentText);
ip.Y += dY;
g.DrawString("Loan Amount:", tf, ip);
TextField fldLoanAmountText = new TextField();
fldLoanAmountText.Widget.Page = page;
fldLoanAmountText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldLoanAmountText.Widget.DefaultAppearance.Font = tf.Font;
fldLoanAmountText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldLoanAmountText);
ip.Y += dY;
g.DrawString("Employment Status:", tf, ip);
var fldLoanTypeComboBox = new ComboBoxField();
fldLoanTypeComboBox.Items.Add(new ChoiceFieldItem("Home Loan"));
fldLoanTypeComboBox.Items.Add(new ChoiceFieldItem("Personal Loan"));
fldLoanTypeComboBox.Items.Add(new ChoiceFieldItem("Auto Loan"));
fldLoanTypeComboBox.Items.Add(new ChoiceFieldItem("Education Loan"));
fldLoanTypeComboBox.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldLoanTypeComboBox.Widget.Page = page;
doc.AcroForm.Fields.Add(fldLoanTypeComboBox);
ip.Y += dY;
g.DrawString("Loan Term (in years):", tf, ip);
var fldLoanTermText = new TextField();
fldLoanTermText.Widget.Page = page;
fldLoanTermText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldLoanTermText.Widget.DefaultAppearance.Font = tf.Font;
fldLoanTermText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldLoanTermText);
ip.Y += dY;
g.DrawString("Annual Income:", tf, ip);
var fldAnnualIncomeText = new TextField();
fldAnnualIncomeText.Widget.Page = page;
fldAnnualIncomeText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldAnnualIncomeText.Widget.DefaultAppearance.Font = tf.Font;
fldAnnualIncomeText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldAnnualIncomeText);
ip.Y += dY;
g.DrawString("Monthly Expenses:", tf, ip);
var fldMonthlyExpensesText = new TextField();
fldMonthlyExpensesText.Widget.Page = page;
fldMonthlyExpensesText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldMonthlyExpensesText.Widget.DefaultAppearance.Font = tf.Font;
fldMonthlyExpensesText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldMonthlyExpensesText);
ip.Y += dY;
g.DrawString("Credit Score Text field:", tf, ip);
var fldCreditScoreText = new TextField();
fldCreditScoreText.Widget.Page = page;
fldCreditScoreText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldCreditScoreText.Widget.DefaultAppearance.Font = tf.Font;
fldCreditScoreText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldCreditScoreText);
ip.Y += dY;
g.DrawString("Existing Loans or Debts:", tf, ip);
var fldDebtsText = new TextField();
fldDebtsText.Widget.Page = page;
fldDebtsText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldDebtsText.Widget.DefaultAppearance.Font = tf.Font;
fldDebtsText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldDebtsText);
ip.Y += dY;
g.DrawString("Co-Signer:", tf, ip);
var fldCoSignerText = new TextField();
fldCoSignerText.Widget.Page = page;
fldCoSignerText.Widget.Rect = new RectangleF(ip.X + fldOffset, ip.Y, 72 * 3, fldHeight);
fldCoSignerText.Widget.DefaultAppearance.Font = tf.Font;
fldCoSignerText.Widget.DefaultAppearance.FontSize = tf.FontSize;
doc.AcroForm.Fields.Add(fldCoSignerText);
ip.Y += dY;
When saved to a PDF file, the form appears as shown below:

Populate PDF with User Information
Now that we have the form and the user details, it’s time to populate the PDF with the provided data. By programmatically filling in the values, we can ensure that the user's information is accurately captured in the form. This allows us to store the user's data for future reference and generate a completed form copy to be shared with the customer for their records.
Below, we’ll map the user inputs to the corresponding fields in the PDF using the following C# code:
Flatten and Save the Completed PDF
As the form is filled with user information, the next important step is to flatten the PDF. This converts all interactive form fields into a static, non-editable format. Flattening ensures that the form fields are locked and cannot be edited further to become a permanent part of the document. After flattening, we can save the finalized PDF, readying it to be shared with the customer or stored securely for future reference.
We will use the code below to flatten the document and download the copy on the user's device:
Use this sample to implement the scenario described above. See it in action below:

Ready to try it out? Download Document Solutions for PDF Today!
Conclusion
In this blog, we explored how to create a digital loan request form using the DsPdf API. These forms can be customized for different business needs, making them a flexible and valuable tool for businesses aiming to enhance their form management. Explore our demos to learn more about PDF forms.
If you have any questions, feel free to ask in the comments below!
More References: