.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

PdfGraphicsAcroFormTextBoxField Class

Represents a text box field.

Namespace: DevExpress.Pdf

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

Declaration

public class PdfGraphicsAcroFormTextBoxField :
    PdfGraphicsAcroFormCommonField
Public Class PdfGraphicsAcroFormTextBoxField
    Inherits PdfGraphicsAcroFormCommonField
public class PdfGraphicsAcroFormTextBoxField :
    PdfGraphicsAcroFormCommonField
Public Class PdfGraphicsAcroFormTextBoxField
    Inherits PdfGraphicsAcroFormCommonField
public class PdfGraphicsAcroFormTextBoxField :
    PdfGraphicsAcroFormCommonField
Public Class PdfGraphicsAcroFormTextBoxField
    Inherits PdfGraphicsAcroFormCommonField

Remarks

To create a text box field, call the PdfGraphicsAcroFormField.CreateTextBox method with the specified field name and field rectangle.

Use members of the PdfGraphicsAcroFormTextBoxField class to specify the text box field properties. For example, you can specify the text box text and type using PdfGraphicsAcroFormTextBoxField.Text, PdfGraphicsAcroFormTextBoxField.Type properties.

To specify the text box name, tooltip and appearance, use the PdfGraphicsAcroFormField.Name, PdfGraphicsAcroFormField.ToolTip, PdfGraphicsAcroFormField.Appearance properties.

To add a text box field to PDF graphics, pass a PdfGraphicsAcroFormTextBoxField object representing the text 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.

Examples

This example shows how to create a text box field and add it to a document.

using DevExpress.Pdf;
using System.Drawing;

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

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

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

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

        static void DrawTextBoxField(PdfGraphics graphics) {

            // Create a text box field and specify its location on the page using a RectangleF object.
            PdfGraphicsAcroFormTextBoxField textBox = new PdfGraphicsAcroFormTextBoxField("text box", new RectangleF(0, 10, 200, 30));

            // Specify text box properties.
            textBox.Text = "Text Box";           
            textBox.TextAlignment = PdfAcroFormStringAlignment.Near;
            textBox.Appearance.FontSize = 12;
            textBox.Appearance.BackgroundColor = Color.AliceBlue;          

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

Inheritance

See Also