Skip to main content
.NET Framework 4.5.2+

PdfGraphicsAcroFormCheckBoxField Class

A check box field in PDF Graphics API.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfGraphicsAcroFormCheckBoxField :
    PdfGraphicsAcroFormCommonField

Remarks

To access the PdfGraphicsAcroFormCheckBoxField class, you need to reference the DevExpress.Pdf.Drawing.v21.2 assembly.

Tip

You can use the PdfAcroFormField class to add interactive form fields to a PDF file. Refer to the following article for more information: Interactive Forms in PDF Documents

Create a Form Field

To create a check box field, create a new PdfGraphicsAcroFormCheckBoxField object and pass the field name and location as the constructor parameters.

Specify Form Field Parameters

The following parameters are available:

Parameter API
Form field name Name
Tooltip text ToolTip
Form field state (checked or unchecked) IsChecked
Check box marker shape ButtonStyle
Appearance settings (background and foreground color, font and border options) Appearance

Add a Form Field as Graphics Content

To add a check box field as a graphics content, pass a PdfGraphicsAcroFormCheckBoxField object as a parameter to the PdfGraphics.AddFormField method.

Draw a Form Field on a Page

To draw an interactive field to a page, call one of the following methods:

Example

This example shows how to use PDF Graphics API to create a check box field and add it to a new page.

using DevExpress.Pdf;
using System.Drawing;
//...
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);
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PdfGraphicsAcroFormCheckBoxField class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Inheritance

See Also