Articles in this section
Category / Section

How to create checkbox field class in .NET WebForms PDF?

2 mins read

Check Box Field

We can create the check box field using PdfCheckBoxField Class.

Please refer the below code snippet for adding the check box field in new Pdf document.

C#

//Create a new PDF document.
PdfDocument document = new PdfDocument();
 
//Add a new page to PDF document.
PdfPage page = document.Pages.Add();
 
//Create Check Box field.
PdfCheckBoxField checkBoxField = new PdfCheckBoxField(page, "CheckBox");
 
//Set check box properties.
checkBoxField.ToolTip = "Check Box";
checkBoxField.Bounds = new RectangleF(0, 20, 10, 10);
 
//Add the form field to the document.
document.Form.Fields.Add(checkBoxField);

 

Checkmark Style

We can add different checkmark styles using PdfCheckBoxStyle enum. Checkmark size is depending on the check box field. Please refer the following code snippet.

C#

//Create Check Box field.
PdfCheckBoxField checkBoxField = new PdfCheckBoxField(page, "CheckBox");
 
//Set Check box properties
checkBoxField.Bounds = new RectangleF (50, 230, 8, 8);checkBoxField.Style = PdfCheckBoxStyle.Cross;

 

Please find the different checkmark styles for the check box field from PdfCheckBoxStyle enum.

C#

//Create Check Box field.
PdfCheckBoxField checkBoxField = new PdfCheckBoxField(page, "CheckBox");
 
//Set Check box field style
checkBoxField.Style = PdfCheckBoxStyle.Check;
checkBoxField.Style = PdfCheckBoxStyle.Circle;
checkBoxField.Style = PdfCheckBoxStyle.Cross;
checkBoxField.Style = PdfCheckBoxStyle.Diamond;
checkBoxField.Style = PdfCheckBoxStyle.Square;
checkBoxField.Style = PdfCheckBoxStyle.Star;

 

For example, one check mark style is added to Check Box field can be shown in below code snippet.

C#

//Create a new PDF document.
PdfDocument doc = new PdfDocument();
 
//Add a page.
PdfPage page = doc.Pages.Add();
 
PdfForm form = doc.Form;
 
page.Graphics.DrawString("Qualification:", new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold), PdfBrushes.Black, new PointF(50, 100));
 
//Create Check box field
PdfCheckBoxField checkField = new PdfCheckBoxField(page, "UG");
 
//Set Check box properties
checkField.Bounds = new RectangleF(50, 130, 8, 8);
checkField.Style = PdfCheckBoxStyle.Cross;
 
page.Graphics.DrawString("UG", new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Italic), PdfBrushes.Black, new PointF(80, 130));
 
//Create Check box field
PdfCheckBoxField checkField1 = new PdfCheckBoxField(page, "PG");
 
//Set Check box properties
checkField1.Bounds = new RectangleF(50, 170, 8, 8);
checkField1.Style = PdfCheckBoxStyle.Cross;
 
page.Graphics.DrawString("PG", new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Italic), PdfBrushes.Black, new PointF(80, 170));
 
//Add the form field to the document
form.Fields.Add(checkField);
form.Fields.Add(checkField1);

 


Note:

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

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 forumsDirect-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 sign in to leave a comment
Access denied
Access denied