Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

PdfGraphicsAcroFormCheckBoxField Class

Represents a check box field.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v20.2.Drawing.dll

NuGet Package: DevExpress.Pdf.Drawing

Declaration

public class PdfGraphicsAcroFormCheckBoxField :
    PdfGraphicsAcroFormCommonField

Remarks

The check box field is represented by an instance of the PdfGraphicsAcroFormCheckBoxField class with the specified field name and field rectangle.

The PdfGraphicsAcroFormCheckBoxField class contains properties to specify the check box field on a page. For example, to specify the check box name, tooltip and appearance, use PdfGraphicsAcroFormField.Name, PdfGraphicsAcroFormField.ToolTip, and PdfGraphicsAcroFormField.Appearance properties.

You can also specify whether a check box is in the pushed state using the PdfGraphicsAcroFormCheckBoxField.IsChecked property.

To add a check box field to PDF graphics, pass a PdfGraphicsAcroFormCheckBoxField object representing the check box field as a parameter to the PdfGraphics.AddFormField method. To access PdfGraphics, you need to reference the DevExpress.Pdf.Drawing assembly.

To render a page with the PDF graphics, call one of PdfDocumentProcessor.RenderNewPage overloaded methods.

Example

This example shows how to create a check box field and add it to a PDF document using the Document Creation API.

using DevExpress.Pdf;
using System.Drawing;

namespace AddCheckBoxField {
    class Program {
        static void Main(string[] args) {
            using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {

                // Create an empty document. 
                processor.CreateEmptyDocument("..\\..\\Result.pdf");

                // Create graphics and draw a check box field.
                using (PdfGraphics graphics = processor.CreateGraphics()) {
                    DrawCheckBoxField(graphics);

                    // Render a page with graphics.
                    processor.RenderNewPage(PdfPaperSize.Letter, graphics);
                }
            }
        }

        static void DrawCheckBoxField(PdfGraphics graphics) {

            // Create a check box field specifying its name and location.
            PdfGraphicsAcroFormCheckBoxField checkBox = new PdfGraphicsAcroFormCheckBoxField("check box", new RectangleF(20, 20, 30, 30));

            // Specify check box appearance, checked state, and button style.
            checkBox.Appearance.BackgroundColor = Color.Azure;
            checkBox.Appearance.BorderAppearance = new PdfGraphicsAcroFormBorderAppearance() { Color = Color.Red };
            checkBox.IsChecked = true;
            checkBox.ButtonStyle = PdfAcroFormButtonStyle.Star;

            // Add the field to the document.
            graphics.AddFormField(checkBox);
        }
    }
}

Inheritance

See Also