Skip to main content
All docs
V26.1
  • CheckBoxField Class

    A checkbox form field that allows users to select or clear an option in a PDF document.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public class CheckBoxField :
        FormField

    Remarks

    For more information, refer to the following help topic: DevExpress PDF Document API - Form Fields.

    Example

    How to: Add a Check Box Field to a PDF Document

    The following code snippet adds a checkbox field to a PDF document and binds it to a checkbox widget:

    DevExpress New PDF API library - Check Box Field

    using DevExpress.Docs.Pdf;
    using DevExpress.Drawing.Printing;
    using System.Drawing;
    
    namespace ConsoleApp1;
    
    public class Program {
        public static async Task Main(string[] _) {
            using (PdfDocument pdfDocument = new()) {
                // Add an A4 page to the document.
                Page page = pdfDocument.Pages.Add(DXPaperKind.A4);
    
                float y = 750;
                float step = 30;
                float textHeight = 14f;
    
                // Create a checkbox field and add it to the field collection.
                CheckBoxField agreeField = new("AgreeToTerms");
                pdfDocument.Fields.Add(agreeField);
    
                // Bind the checkbox field to a widget and place it on the page.
                RectangleF agreeBounds = new(50, y - textHeight + 6, 18, 18);
                CheckBoxWidgetAnnotation agreeWidget = new(agreeField, agreeBounds);
                page.Annotations.Add(agreeWidget);
                y -= step;
    
                // Add a label for the checkbox field.
                TextFragment labelAgreeField = new() { Text = "Agree to terms", Location = new PointF(agreeBounds.X + 30, agreeBounds.Y + 6) };
                page.Fragments.Add(labelAgreeField);
            }
        }
    }
    

    Implements

    Inheritance

    Object
    FormField
    CheckBoxField
    See Also