Articles in this section
Category / Section

How to create checkbox groups in PDF document using ASP.NET Core?

2 mins read

The Syncfusion Essential PDF is a feature-rich and high performance .NET PDF library used to create, read, and edit PDF documents programmatically without Adobe dependencies. Using this library, you can create a group of checkboxes in a PDF document using C#.

Steps to create group of checkboxes in a PDF document programmatically:

  1. Create a new console application project.Screenshot (1337).png
  2. Install the Syncfusion.Pdf.Net.Core NuGet package as a reference to your console application from Nuget.org.
    Screenshot (1339).png
  3. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.Pdf;
using Syncfusion.Pdf.Interactive;

VB.NET

Imports Syncfusion.Pdf
Imports Syncfusion.Pdf.Interactive
  1. Use the following code sample in Program.cs to create group of checkboxes in a PDF document.

C#

//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Add a new page to PDF document.
PdfPage page = document.Pages.Add();
// Get the form object from the PDF document
PdfForm form = document.Form;
// Disable auto-naming for form fields
form.FieldAutoNaming = false;

//Create Check Box field with the name of CheckBox1.
PdfCheckBoxField checkBoxField = new PdfCheckBoxField(page, "CheckBox1");
//Set check box properties.
checkBoxField.ToolTip = "Check Box";
checkBoxField.Bounds = new Syncfusion.Drawing.RectangleF(0, 20, 10, 10);
//Add the checkbox to the form.
form.Fields.Add(checkBoxField);

//Create Check Box field with the name of CheckBox1.
PdfCheckBoxField checkBoxField1 = new PdfCheckBoxField(page, "CheckBox1");
//Set check box properties.
checkBoxField1.ToolTip = "Check Box";
checkBoxField1.Bounds = new Syncfusion.Drawing.RectangleF(0, 40, 10, 10);
//Add the checkbox to the form.
form.Fields.Add(checkBoxField1);
//Save and dispose the document.
MemoryStream stream = new MemoryStream();
document.Save(stream);
File.WriteAllBytes("Output.pdf", stream.ToArray());
document.Close(true);

VB.NET

' Create a new PDF document.
Dim document As New PdfDocument()
' Add a new page to PDF document.
Dim page As PdfPage = document.Pages.Add()
' Get the form object from the PDF document
Dim form As PdfForm = document.Form
' Disable auto-naming for form fields
form.FieldAutoNaming = False

' Create Check Box field with the name of CheckBox1.
Dim checkBoxField As New PdfCheckBoxField(page, "CheckBox1")
' Set check box properties.
checkBoxField.ToolTip = "Check Box"
checkBoxField.Bounds = New Syncfusion.Drawing.RectangleF(0, 20, 10, 10)
' Add the checkbox to the form.
form.Fields.Add(checkBoxField)

' Create Check Box field with the name of CheckBox1.
Dim checkBoxField1 As New PdfCheckBoxField(page, "CheckBox1")
' Set check box properties.
checkBoxField1.ToolTip = "Check Box"
checkBoxField1.Bounds = New Syncfusion.Drawing.RectangleF(0, 40, 10, 10)
' Add the checkbox to the form.
form.Fields.Add(checkBoxField1)

Dim stream As New MemoryStream()
document.Save(stream)
File.WriteAllBytes("Output.pdf", stream.ToArray())
document.Close(True)

A complete working sample can be downloaded from Create_group_of_checkboxes.zip

By executing the program, you will get the PDF document as follows.Screenshot (1395).png

Take a moment to peruse the documentation for PDF Form filling and sign a PDF file, where you will find other options like modifying existing form fields, filling form fields, removing editing capability, removing form fields, importing FDF file to PDF, export PDF file to FDF, adding actions to form fields, and adding a timestamp in digital signature.

Refer here to explore the rich set of Syncfusion Essential PDF features.

Conclusion
I hope you enjoyed learning about how to create checkbox groups in PDF document using ASP.NET Core.

You can refer to our ASP.NET Core PDF feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET Core PDF example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied