C# PDF Generator Library
How to add form fields to PDF file using C#
C# Demo Code to add a form fields to adobe pdf file
In this C# tutorial, you will learn how to add AcroForms fields to PDF file without Adobe Acrobat installed, using C# in ASP.NET MVC Web, Windows applications.
- Quick to add new form fields to PDF document
- Customize the fields with default value, width, height settings
Add text box form field to PDF using C#
The following C# source code will show how to add text box field to PDF document using C#
- Use class PDFBuildHandler to create a new PDF and start content editing
- Create a new FormFieldTextBox object for the form text box field
- Custumize the text box field with default text content, width, and height
- Apply the PDF document changes and save to the PDF file
String outputFilePath = Program.RootPath + "\\" + "Sample91.pdf";
Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);
document.Open();
document.Add(new Paragraph("This is a sample for Text Form Field:"));
document.Add(new Paragraph(" "));
// create a Text Box form field
FormFieldTextBox textBox = new FormFieldTextBox("TextBox1");
textBox.Text = " ";
textBox.Width = 400;
textBox.Height = 100;
// add form field
document.Add(textBox);
document.Close();
Add check box form field
String outputFilePath = Program.RootPath + "\\" + "Sample92.pdf";
Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);
document.Open();
document.Add(new Paragraph("This is a sample for Text Form Field:"));
document.Add(new Paragraph(" "));
// create a Text Box form field
FormFieldCheckBox checkbox = new FormFieldCheckBox("CheckBox1");
checkbox.Text = " ";
checkbox.Width = 50;
checkbox.Height = 50;
// add form field
document.Add(checkbox);
document.Close();