Skip to main content

How to: Use PDF Graphics API to Add Interactive Form Fields

  • 3 minutes to read


You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use these examples in production code.

This example shows how to use PDF Graphics API to add interactive form fields – text box and radio button group.

View Example

using DevExpress.Pdf;
using System.Drawing;

using (var processor = new PdfDocumentProcessor()) {
    // Create an empty document.

    // Create graphics and draw form fields.
    using (PdfGraphics graphics = processor.CreateGraphics()) {

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

static void DrawFormFields(PdfGraphics graphics){
    // Create a text box field and specify its location on the page.
    var textBox =
         new PdfGraphicsAcroFormTextBoxField("text box", new RectangleF(30, 10, 200, 30));

    // Specify text and appearance parameters.
    textBox.Text = "Text Box";
    textBox.Appearance.FontSize = 12;
    textBox.Appearance.BackgroundColor = Color.AliceBlue;

    // Add the text box field to graphics.

    // Create a radio group field.
    var radioGroup =
         new PdfGraphicsAcroFormRadioGroupField("First Group");

    // Add the first radio button to the group and specify its location.
    radioGroup.AddButton("button1", new RectangleF(30, 60, 20, 20));

    // Add the second radio button to the group.
    radioGroup.AddButton("button2", new RectangleF(30, 90, 20, 20));

    // Specify radio group selected index
    radioGroup.SelectedIndex = 0;

    // Specify appearance options:
    radioGroup.Appearance.BorderAppearance =
         new PdfGraphicsAcroFormBorderAppearance()
            Color = Color.Red,
            Width = 3

    // Add the radio group field to graphics.
See Also