Examples

Adding Form Fields to PDF

Add form fields such as buttons, checkboxes, combo boxes, list boxes, radio buttons, and text fields to a PDF document. DynamicPDF Core Suite for .NET makes creating interactive forms a breeze, as the following examples illustrate.

Hot to Add Button to PDF

The following steps and C# sample code illustrates adding a Button to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a Button to a PDF Document

  1. Create a Document object.
  2. Create a Page object.
  3. Create a Button object and set its properties.
  4. Add the Button instance to the Page instance.
  5. Add the Page instance to the Document instance.
  6. Add the Draw method to output the PDF document.

Sample Code - C#

Document document = new Document();
Page page = new Page(PageSize.Letter);
Button button = new Button("btn", 50, 50, 100, 50);
button.Action = new JavaScriptAction("app.alert('Hello');");
button.Label = "Click";            
page.Elements.Add(button);
document.Pages.Add(page);
document.Draw("Output.pdf");        

How to Add CheckBox to PDF

The following steps and C# sample code add a CheckBox to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a Checkbox to a PDF Document

  1. Create a Document object.
  2. Create Page object.
  3. Create a CheckBox object and set its properties.
  4. Add the CheckBox instance to the Page instance
  5. Add the Page instance to Document instance.
  6. Add the Draw method to output the PDF document.

Sample Code - C#

Document document = new Document();
Page page = new Page(PageSize.Letter);         
CheckBox checkBox = new CheckBox( "Check Box Name", 5, 7, 50, 50 );
checkBox.DefaultChecked = true;
checkBox.ToolTip = "Check it";
page.Elements.Add(checkBox);
document.Pages.Add(page);
document.Draw("Output.pdf");        

How to Add ComboBox to PDF

The following steps and C# sample code illustrate adding a ComboBox to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a ComboBox to a PDF Document

  1. Create a Document object.
  2. Create a Page object.
  3. Create a ComboBox object and set its properties.
  4. Add the ComboBox instance to the Page instance.
  5. Add the Page instance to the Document object instance.
  6. Add the Draw method to output the PDF document.

Sample Code - C#

Document document = new Document();
Page page = new Page(PageSize.Letter);
ComboBox comboBox = new ComboBox( "Combo Box Name", 50, 75, 150, 25);
comboBox.Items.Add("One", true);
comboBox.Items.Add("Two");
comboBox.Items.Add("Three");
comboBox.BackgroundColor = RgbColor.AliceBlue;
comboBox.BorderColor = RgbColor.DarkMagenta;
comboBox.Editable = true;
comboBox.ToolTip = "Select"; 
page.Elements.Add(comboBox);
document.Pages.Add(page);
document.Draw("Output.pdf");        

How to Add ListBox to PDF

The following steps and C# sample code illustrate adding a ListBox to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a ListBox to a PDF Document

  1. Create a Document object.
  2. Create a Page object.
  3. Create a ListBox object and set its properties.
  4. Add the ListBox object to the Page object.
  5. Add the Page object to the Document object.
  6. Add the Draw method to output the PDF document.

Sample Code - C#

Document document = new Document();
Page page = new Page(PageSize.Letter);          
ListBox listBox = new ListBox( "List Box Name", 5, 2, 100, 150 );
listBox.Items.Add( "One",true );
listBox.Items.Add( "Two",true );
listBox.Items.Add( "Three" );
listBox.BackgroundColor = RgbColor.AliceBlue;
listBox.BorderColor = RgbColor.DarkMagenta;
listBox.BorderStyle = BorderStyle.Dashed;
listBox.Multiselect = true;
listBox.ToolTip = "Select"; 
page.Elements.Add(ListBox);
document.Pages.Add(page);
document.Draw("Output.pdf");        

How to Add Radio Button to PDF

The following steps and C# sample code illustrate adding a Radio Button to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a RadioButton to a PDF Document

  1. Create a Document object.
  2. Create a Page object.
  3. Create a RadioButton object and set its properties.
  4. Add the RadioButton object instance to the Page instance.
  5. Add the Page object to the Document object.
  6. Add the Draw method to output the PDF document.

Sample Code - C#

Document document = new Document();
Page page = new Page(PageSize.Letter);  
RadioButton radio1 = new RadioButton( "Radio Button Name", 50, 25, 100, 75 );
radio1.DefaultChecked = true;
radio1.ExportValue = "abc";
radio1.ToolTip = "first";
RadioButton radio2 = new RadioButton( "Radio Button Name", 50, 140, 100, 75 );
radio2.ExportValue = "def";
radio2.ToolTip = "second";
RadioButton radio3 = new RadioButton( "Radio Button Name", 50, 250, 100, 75 );
radio3.ExportValue = "ghi";
radio3.ToolTip = "third";   
page.Elements.Add(radio1);
page.Elements.Add(radio2);
page.Elements.Add(radio3);
document.Pages.Add(page);
document.Draw("Output.pdf");        

How to Add Text Field to PDF

The following steps and C# sample code add a TextField to a PDF document using DynamicPDF Core Suite for .NET.

Steps for Adding a TextField to PDF Document

  1. Create a Document object.
  2. Create a Page object.
  3. Create a TextField object and set its properties.
  4. Add the TextField object to the Page object.
  5. Add the Page object to the Document object.
  6. Add the Draw method to output the PDF document.

Sample Code - C#

Document document = new Document();
Page page = new Page(PageSize.Letter);        
TextField textField = new TextField( "Text Field Name", 50, 75, 150, 100 );
textField.TextAlign = Align.Center;
textField.BackgroundColor = RgbColor.AliceBlue;
textField.BorderColor = RgbColor.DeepPink;
textField.Font = Font.TimesItalic;
textField.FontSize = 16.0f;
textField.TextColor = RgbColor.Brown;
textField.DefaultValue = "ceTe Software";
textField.MultiLine = true;
textField.ToolTip = "Text";
page.Elements.Add(textField);
document.Pages.Add(page);
document.Draw(@"Output.pdf");        

GitHub Project

An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub

Clone or View Example Project on GitHub

Getting Started

Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing the product.

NuGet Package

The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information

DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!

More Information on Form Fields

Available on Other Platforms

DynamicPDF Core Suite is also available for the Java and COM/ActiveX 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 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

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