PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.
- How to use a system font for rendering text
- Customize the GUI interaction of a radio button
- Customize the UI interaction of a check box
- How to reduce PDF file size
- How do I create graphics with Icc based colors
- Draw interactively on a PDF page
- Verify a custom digital PDF signature
- How do I use PDFControls.NET in a WPF application
- Fill PDF form
- Flatten PDF form
- Digitally sign a PDF form in C# or VB.NET
- C# render pdf in browser using MVC
- Add hyperlink to PDF
- Rotate a PDF page
- Change the formatting of a numeric field
- Override MouseWheel event
- How to create a thumbnail viewer
- EMF to PDF as vector image
- EMF to PDF as raster image
- Add a rubber stamp annotation with a custom icon
- Create a text annotation in PDF with rich text
- Read and write meta data from PDF
- Use multiple licenses
Fill PDF form
This code sample shows how to assign values to various types of PDF form fields.
C#
using (var fileIn = new FileStream("form.pdf", FileMode.Open, FileAccess.Read))
{
// open PDF
Document document = new Document(fileIn);
// set the value of text field
TextField textField = document.Fields["Text1"] as TextField;
textField.Value = "Hello";
// check check box
CheckBoxField checkBox = document.Fields["CheckBox2"] as CheckBoxField;
checkBox.CheckBoxValue = CheckState.On;
// select second radio button option
// (range checking omitted for the purpose of this code sample)
RadioButtonField radioButton = document.Fields["Radio Button4"] as RadioButtonField;
radioButton.RadioButtonValue = radioButton.Options[0]; //select first option
// select second item in list box
ListBoxField listBox = document.Fields["ListBox7"] as ListBoxField;
listBox.ListBoxValue = new ListOption[] { listBox.Options[1] }; // select second option
// set the value of a drop down
DropDownListField dropDown = document.Fields["ComboBox8"] as DropDownListField;
dropDown.DropDownListValue = dropDown.Options[1]; // select second option
// save PDF
using (var fileOut = new FileStream("filled.pdf", FileMode.Create, FileAccess.Write))
{
document.Write(fileOut);
}
}
Using fileIn As New FileStream("..\..\..\inputDocuments\fields.pdf", FileMode.Open, FileAccess.Read)
Dim document As New Document(fileIn)
Dim textField As TextField = TryCast(document.Fields("Text1"), TextField)
textField.Value = "Hello"
Dim checkBox As CheckBoxField = TryCast(document.Fields("Check Box2"), CheckBoxField)
checkBox.CheckBoxValue = CheckState.[On]
Dim radioButton As RadioButtonField = TryCast(document.Fields("Radio Button4"), RadioButtonField)
radioButton.RadioButtonValue = radioButton.Options(1)
' second option
Dim listBox As ListBoxField = TryCast(document.Fields("List Box7"), ListBoxField)
listBox.ListBoxValue = New ListOption() {listBox.Options(1)}
' second option
Dim dropDown As DropDownListField = TryCast(document.Fields("Combo Box8"), DropDownListField)
dropDown.DropDownListValue = dropDown.Options(1)
' second option
Using fileOut As New FileStream("..\..\fillfields.pdf", FileMode.Create, FileAccess.Write)
document.Write(fileOut)
End Using
End Using

Download PDFControls.NET 2.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download
We have sent an email with a download link.