Add Form Fields to PDF in C#

Different types of Form Fields can be added to PDF easily using DynamicPDF Generator product. Form fields like Text Field, Button, Checkbox, Radio button, Combobox can be added to a PDF document.

How to add form fields to PDF in C#

Below are the steps and sample code to add differnt types of form fields to PDF document using the Generator product.

Steps for adding form fields to PDF Document

  1. Create a Document object.
  2. Create and add a Page to the document.
  3. Create a TextField page element.
  4. Add the textfield to the page.
  5. Create a Button page element.
  6. Add the button to the page.
  7. Create a CheckBox page element.
  8. Add the checkbox to the Page.
  9. Create a RadioButton page element.
  10. Add the radio button to the page.
  11. Create a ComboBox page element.
  12. Add the combo box to the page.
  13. Save the PDF document.

Sample Code - C#

Document document = new Document();
 
Page page = new Page();
document.Pages.Add(page);
 
ceTe.DynamicPDF.PageElements.Forms.TextField textField = new ceTe.DynamicPDF.PageElements.Forms.TextField("Text Field Name", 50, 50, 150, 100);
textField.DefaultValue = "ceTe Software";
page.Elements.Add(textField);
 
Button button = new Button("Button Name", 50, 180, 100, 50);
button.Action = new JavaScriptAction("app.alert('Hello');");
button.Label = "Push";
page.Elements.Add(button);
 
CheckBox checkBox = new CheckBox("Check Box Name", 50, 250, 50, 50);
checkBox.DefaultChecked = true;
page.Elements.Add(checkBox);
 
RadioButton radio1 = new RadioButton("First", 50, 320, 100, 75);
radio1.DefaultChecked = true;
radio1.ExportValue = "abc";
page.Elements.Add(radio1);
 
ComboBox comboBox = new ComboBox("Combo Box Name", 50, 420, 150, 25);
comboBox.Items.Add("One", true);
comboBox.Items.Add("Two");
comboBox.Items.Add("Three");
comboBox.Editable = true;
page.Elements.Add(comboBox);
 
document.Draw(@"C:\MyDocument.pdf");

Getting Started

NuGet Package

DynamicPDF Generator is available on NuGet and is part of the ceTe.DynamicPDF.CoreSuite.NET package. The Core Suite package includes Generator, Merger and ReportWriter.

Nuget Logo
NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

Example Project

An example project showing this functionality can be cloned or viewed from GitHub:

GitHub Logo
Clone or View Example Project on GitHub

DynamicPDF Generator Information

More information can be found here:

Available in Other Platforms

Generator Libraries are available for Java and COM/AxtiveX platforms. Refer to the respective product pages for more details.

Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 18 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!