Class PdfCheckBoxField
Represents check box field in the PDF form.
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Interactive
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfCheckBoxField : PdfCheckFieldBase, IPdfWrapper, INotifyPropertyChanged
Remarks
This PdfButtonField class is used to add the check box field to the PDF form. Please refer the UG documentation link https://help.syncfusion.com/file-formats/pdf/working-with-forms#adding-the-check-box-field for more details.
Examples
//Create a new PDf document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfBrush brush = PdfBrushes.Black;
PdfGraphics graphics = page.Graphics;
//Create a check box
PdfCheckBoxField checkBox = new PdfCheckBoxField(page, "C#.NET");
checkBox.Bounds = new RectangleF(100, 290, 20, 20);
checkBox.HighlightMode = PdfHighlightMode.Push;
checkBox.BorderStyle = PdfBorderStyle.Beveled;
//Set the value for the check box
checkBox.Checked = true;
document.Form.Fields.Add(checkBox);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim brush As PdfBrush = PdfBrushes.Black
Dim graphics As PdfGraphics = page.Graphics
'Create a check box
Dim checkBox As PdfCheckBoxField = New PdfCheckBoxField(page, "C#.NET")
checkBox.Bounds = New RectangleF(100, 290, 20, 20)
checkBox.HighlightMode = PdfHighlightMode.Push
checkBox.BorderStyle = PdfBorderStyle.Beveled
'Set the value for the check box
checkBox.Checked = True
document.Form.Fields.Add(checkBox)
document.Save("Form.pdf")
document.Close(True)
Constructors
PdfCheckBoxField(PdfPageBase, String)
Initializes a new instance of the PdfCheckBoxField class with the specific page and name.
Declaration
public PdfCheckBoxField(PdfPageBase page, string name)
Parameters
| Type | Name | Description |
|---|---|---|
| PdfPageBase | page | The page where the fields should be placed. |
| System.String | name | The name of the check box field. |
Examples
//Create a new PDf document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfBrush brush = PdfBrushes.Black;
PdfGraphics graphics = page.Graphics;
//Create a check box
PdfCheckBoxField checkBox = new PdfCheckBoxField(page, "C#.NET");
checkBox.Bounds = new RectangleF(100, 290, 20, 20);
checkBox.HighlightMode = PdfHighlightMode.Push;
checkBox.BorderStyle = PdfBorderStyle.Beveled;
//Set the value for the check box
checkBox.Checked = true;
document.Form.Fields.Add(checkBox);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim brush As PdfBrush = PdfBrushes.Black
Dim graphics As PdfGraphics = page.Graphics
'Create a check box
Dim checkBox As PdfCheckBoxField = New PdfCheckBoxField(page, "C#.NET")
checkBox.Bounds = New RectangleF(100, 290, 20, 20)
checkBox.HighlightMode = PdfHighlightMode.Push
checkBox.BorderStyle = PdfBorderStyle.Beveled
'Set the value for the check box
checkBox.Checked = True
document.Form.Fields.Add(checkBox)
document.Save("Form.pdf")
document.Close(True)
See Also
Properties
Checked
Gets or sets a value indicating whether this PdfCheckBoxField is checked.
Declaration
public bool Checked { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
Examples
//Create a new PDf document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
PdfBrush brush = PdfBrushes.Black;
PdfGraphics graphics = page.Graphics;
//Create a check box
PdfCheckBoxField checkBox = new PdfCheckBoxField(page, "C#.NET");
//Set the value for the check box
checkBox.Checked = true;
checkBox.Bounds = new RectangleF(100, 290, 20, 20);
checkBox.HighlightMode = PdfHighlightMode.Push;
checkBox.BorderStyle = PdfBorderStyle.Beveled;
//Set the value for the check box
checkBox.Checked = true;
document.Form.Fields.Add(checkBox);
document.Save("Form.pdf");
document.Close(true);
'Create a new PDf document
Dim document As PdfDocument = New PdfDocument()
'Create a page
Dim page As PdfPage = document.Pages.Add()
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
Dim brush As PdfBrush = PdfBrushes.Black
Dim graphics As PdfGraphics = page.Graphics
'Create a check box
Dim checkBox As PdfCheckBoxField = New PdfCheckBoxField(page, "C#.NET")
'Set the value for the check box
checkBox.Checked = True
checkBox.Bounds = New RectangleF(100, 290, 20, 20)
checkBox.HighlightMode = PdfHighlightMode.Push
checkBox.BorderStyle = PdfBorderStyle.Beveled
'Set the value for the check box
checkBox.Checked = True
document.Form.Fields.Add(checkBox)
document.Save("Form.pdf")
document.Close(True)
See Also
ExportValue
Gets or sets the export value of the checkbox field.
Declaration
public string ExportValue { get; set; }
Property Value
| Type |
|---|
| System.String |
Remarks
The export value determines what is written to the data stream when a checkbox is checked. Typically, "Off" represents an unchecked checkbox, so it is recommended to use a different value for a checked state to avoid confusion.
Examples
// Create a new PDF document.
PdfDocument document = new PdfDocument();
// Add a new page to the document.
PdfPage page = document.Pages.Add();
// Create a new checkbox field.
PdfCheckBoxField checkBoxField = new PdfCheckBoxField(page, "CheckBox");
// Set properties for the checkbox field.
checkBoxField.Bounds = new RectangleF(10, 150, 200, 80);
checkBoxField.BorderColor = Color.Red;
checkBoxField.BorderWidth = 10;
checkBoxField.BackColor = Color.Yellow;
checkBoxField.ExportValue = "Value";
checkBoxField.Checked = true;
// Add the checkbox to the form fields collection.
document.Form.Fields.Add(checkBoxField);
// Save the document to a file.
document.Save("output.pdf");
document.Close(true);
Methods
DrawAppearance()
Draws the appearance of the field.
Declaration
protected override void DrawAppearance()