How to add the different check mark style in checkbox field ?
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);