# How to Create and Deploy PDF Forms in ASP.NET Core C#

> TX Text Control can be used for the creation and editing of form fields in PDF documents. This article explains how to create a PDF form from scratch and how to deploy the form using the Document Viewer.

- **Author:** Bjoern Meyer
- **Published:** 2023-10-17
- **Modified:** 2025-11-16
- **Description:** TX Text Control can be used for the creation and editing of form fields in PDF documents. This article explains how to create a PDF form from scratch and how to deploy the form using the Document Viewer.
- **4 min read** (703 words)
- **Tags:**
  - ASP.NET
  - ServerTextControl
  - PDF
  - Forms
  - AcroForms
- **Web URL:** https://www.textcontrol.com/blog/2023/10/17/how-to-create-and-deploy-pdf-forms-in-aspnet-core-csharp/
- **LLMs URL:** https://www.textcontrol.com/blog/2023/10/17/how-to-create-and-deploy-pdf-forms-in-aspnet-core-csharp/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2023/10/17/how-to-create-and-deploy-pdf-forms-in-aspnet-core-csharp/llms-full.txt

---

TX Text Control offers extensive functionality to create and deploy PDF forms, including form text boxes, checkboxes, and combo boxes.

This article describes how to use TX Text Control to create PDF documents with form fields and how to deploy the document using Document Viewer with the PDF.js rendering option.

It uses a simple ASP.NET Core Web App (MVC) to create a document that uses the ServerTextControl class to create the PDF form fields.

### Creating the Application

Make sure that you downloaded the latest version of Visual Studio 2022 that comes with the [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0).

> ### Prerequisites
> 
>  The following tutorial requires a trial version of TX Text Control .NET Server.
> 
> - [Download Trial Version](https://www.textcontrol.com/product/tx-text-control-dotnet-server/download/)

1. In Visual Studio 2022, create a new project by choosing *Create a new project*.
2. Select *ASP.NET Core Web App (Model-View-Controller)* as the project template and confirm with *Next*.
3. Choose a name for your project and confirm with *Next*.
4. In the next dialog, choose *.NET 6 (Long-term support)* as the *Framework* and confirm with *Create*.

#### Adding the NuGet Packages

5. In the *Solution Explorer*, select your created project and choose *Manage NuGet Packages...* from the *Project* main menu.
    
    Select *Text Control Offline Packages* from the *Package source* drop-down.
    
    > **Package Source**
    > 
    > Select either **Text Control Offline Packages** or **nuget.org** as the *Package source*. Packages in the official *Text Control* NuGet profile are frequently updated.
    
    *Install* the latest versions of the following packages:
    
    
    - *TXTextControl.Web.DocumentViewer*
    - *TXTextControl.TextControl.ASP.SDK*
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2023/10/17/a/assets/visualstudio2.webp "ASP.NET Core Web Application")
6. Switch the package source to *nuget.org* and choose *Installed* to check for available updates. Update the installed packages to the most current version.
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2023/10/17/a/assets/updates.webp "ASP.NET Core Web Application")

#### Adding PDF.js

7. In the *Solution Explorer*, select your created project and choose *Add -> Client-Side Library...* from the right-click context menu.
8. Search for *pdf.js* by typing it into the *Library* text box and confirm with *Install*.
    
    ![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2023/10/17/a/assets/visualstudio3.webp "ASP.NET Core Web Application")

#### Adding the Document Viewer

9. Find the *Index.cshtml* file in the *Views -> Home* folder. Replace the complete content with the following code:
    
    ```
    @model byte[]
    
    @using TXTextControl.Web.MVC.DocumentViewer
    @using System.Text
    	        
    <div style="width: 800px; height: 600px;">
    	    
    @Html.TXTextControl().DocumentViewer(settings => {
    	settings.DocumentData = Convert.ToBase64String(Model);
    	settings.Dock = DocumentViewerSettings.DockStyle.Fill;
    	settings.DocumentLoadSettings.PDFJS.BasePath = "/lib/pdf.js/";
    }).Render()
    	    
    </div>
    ```
    
    This code adds the DocumentViewer to the view and loads the PDF document that has been created from the model.

#### Creating the PDF Form

10. Find the *HomeController.cs* and replace the *Index()* method with the following code:
    
    ```
    public IActionResult Index()
    {
    	byte[] bDocument = null;
    
    	using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
    	{
    		tx.Create();
    
    		tx.Selection.FontSize = 800;
    		tx.Selection.Text = "Sample Form\r\n\r\n";
    
    		tx.Selection.FontSize = 400;
    		tx.Selection.Text = "Company name:\r\n";
    
    		// add a text form field
    		TXTextControl.TextFormField textFormField = new TXTextControl.TextFormField(1000);
    		textFormField.Name = "company_name";
    		textFormField.Text = "Text Control, LLC";
    		tx.FormFields.Add(textFormField);
    
    		tx.Selection.Text = "\r\n\r\nCountry:\r\n";
    
    		// add a text form field
    		TXTextControl.SelectionFormField selectionFormField = new TXTextControl.SelectionFormField(1000);
    		selectionFormField.Name = "company_country";
    		selectionFormField.Items = new string[] { "United States", "Germany", "Italy" };
    		selectionFormField.Editable = true;
    
    		tx.FormFields.Add(selectionFormField);
    
    		tx.InputPosition = new TXTextControl.InputPosition(-1, TXTextControl.TextFieldPosition.OutsideTextField);
    
    		tx.Selection.Text = "\r\n\r\nTaxable:\r\n";
    
    		// add a text form field
    		TXTextControl.CheckFormField checkFormField = new TXTextControl.CheckFormField(false);
    		checkFormField.Name = "company_taxable";
    		checkFormField.CheckedCharacter = 'X';
    		checkFormField.UncheckedCharacter = 'O';
    		tx.FormFields.Add(checkFormField);
    
    		// save in the internal format
    		tx.Save(out bDocument, TXTextControl.BinaryStreamType.AdobePDF);
    		tx.Save("test.pdf", TXTextControl.StreamType.AdobePDF);
    
    	}
    
    	return View(bDocument);
    }
    ```

Compile and start the application.

![ASP.NET Core Web Application](https://s1-www.textcontrol.com/assets/dist/blog/2023/10/17/a/assets/results.webp "ASP.NET Core Web Application")

> **Learn More**
> 
> Read this article to learn how to pre-select form fields or flatten completed forms.
> 
> [Create, Pre-Select, Flatten and Extract PDF Form Fields using C# ](https://www.textcontrol.com/blog/2023/08/14/create-preselect-flatten-and-extract-pdf-form-fields-using-csharp/llms-full.txt)

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [How to Load and View PDF Documents in ASP.NET Core C#](https://www.textcontrol.com/blog/2023/10/20/how-to-load-and-view-pdf-documents-in-aspnet-core-csharp/llms.txt)
- [Programmatically Fill, Flatten, and Export DOCX Form Templates to PDF in C# .NET](https://www.textcontrol.com/blog/2026/04/10/programmatically-fill-flatten-and-export-docx-form-templates-to-pdf-in-csharp-dotnet/llms.txt)
- [Create Fillable PDFs from HTML Forms in C# ASP.NET Core Using a WYSIWYG Template](https://www.textcontrol.com/blog/2026/03/17/create-fillable-pdfs-from-html-forms-in-csharp-aspnet-core-using-a-wysiwyg-template/llms.txt)
- [Designing the Perfect PDF Form with TX Text Control in .NET C#](https://www.textcontrol.com/blog/2025/12/16/designing-the-perfect-pdf-form-with-tx-text-control-in-dotnet-csharp/llms.txt)
- [Streamline Data Collection with Embedded Forms in C# .NET](https://www.textcontrol.com/blog/2025/08/02/streamline-data-collection-with-embedded-forms-in-csharp-dotnet/llms.txt)
- [Convert MS Word DOCX to PDF with Form Fields in C# .NET: Preserve or Flatten Form Fields](https://www.textcontrol.com/blog/2025/02/26/convert-ms-word-docx-to-pdf-with-form-fields-in-csharp-dotnet/llms.txt)
- [Export and Import Adobe PDF XFDF XML Files in .NET C#](https://www.textcontrol.com/blog/2025/01/22/export-and-import-adobe-pdf-xfdf-xml-files-in-net-c-sharp/llms.txt)
- [Sign Documents with a Self-Signed Digital ID From Adobe Acrobat Reader in .NET C#](https://www.textcontrol.com/blog/2024/08/12/sign-documents-with-a-self-signed-digital-id-from-adobe-acrobat-reader-in-net-c-sharp/llms.txt)
- [Programmatically Convert MS Word DOCX Documents to PDF in .NET C#](https://www.textcontrol.com/blog/2024/08/09/programmatically-convert-ms-word-docx-documents-to-pdf-in-net-c-sharp/llms.txt)
- [Chat PDF - A Generative AI Application for PDF Documents using TX Text Control and OpenAI Functions in C#](https://www.textcontrol.com/blog/2024/02/23/ask-pdf-a-generative-ai-application-for-pdf-documents-using-tx-text-control-and-openai-functions-in-c-sharp/llms.txt)
- [Document Viewer: Save the Values of Form Fields in Documents](https://www.textcontrol.com/blog/2023/12/19/document-viewer-save-the-values-of-form-fields-in-documents/llms.txt)
- [Store Documents as PDF/A using C# - A Future-Proof Archiving Format](https://www.textcontrol.com/blog/2023/10/24/store-documents-as-pdfaa-using-csharp-a-futureproof-archiving-format/llms.txt)
- [Convert HTML to PDF in ASP.NET Core C#](https://www.textcontrol.com/blog/2023/10/23/convert-html-to-pdf-in-aspnet-core-csharp/llms.txt)
- [Generate PDF Documents from MS Word DOCX Templates in ASP.NET Core C#](https://www.textcontrol.com/blog/2023/10/20/generate-pdf-documents-from-ms-word-docx-templates-in-aspnet-core-csharp/llms.txt)
- [Document Viewer: Save the Values of Form Fields in Documents](https://www.textcontrol.com/blog/2023/10/19/document-viewer-save-the-values-of-form-fields-in-documents/llms.txt)
- [Healthcare Use Case: Digital Forms Workflow with Electronic Signatures](https://www.textcontrol.com/blog/2023/03/15/healthcare-use-case-digital-forms-workflow-with-electronic-signatures/llms.txt)
- [Auto-Generate HTML Forms from PDF AcroForms in C#](https://www.textcontrol.com/blog/2023/03/06/autogenerate-html-forms-from-pdf-acroforms-in-csharp/llms.txt)
- [Generating Interactive PDF Forms by Injecting JavaScript](https://www.textcontrol.com/blog/2022/03/31/generating-interactive-pdf-forms-by-injecting-javascript/llms.txt)
- [Creation of Custom Electronic Signature Boxes](https://www.textcontrol.com/blog/2021/06/15/creation-of-custom-electronic-signature-boxes/llms.txt)
- [Don't Print Your Documents! Streamlined Document Processes in Your Applications](https://www.textcontrol.com/blog/2021/06/09/dont-print-your-documents/llms.txt)
- [Importing Form Data from PDF Documents Exported from Chrome](https://www.textcontrol.com/blog/2021/02/11/importing-form-data-from-pdf-documents-exported-from-chrome/llms.txt)
- [Creating Adobe PDF Forms in C#](https://www.textcontrol.com/blog/2021/02/10/creating-adobe-pdf-forms-in-csharp/llms.txt)
- [X19 Sneak Peek: Processing AcroForm Fields in Adobe PDF Documents](https://www.textcontrol.com/blog/2020/10/29/sneak-peek-processing-acroform-fields-from-adobe-pdf-documents/llms.txt)
