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

    A text box form field that allows users to enter text in a PDF document.

    Namespace: DevExpress.Docs.Pdf

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

    Declaration

    public class TextBoxField :
        FormField

    Remarks

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

    Example

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

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

    DevExpress New PDF API library - Text 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);
    
                TextFont textFont = new("SegoeUI", TextFontStyle.Regular);
    
                float y = 750;
                float step = 30;
                float textHeight = 14f;
    
                // Create a label for the text field.
                TextFragment loginLabel = new() {
                    Text = "Login:",
                    Location = new PointF(50, y - textHeight / 2),
                    Font = textFont
                };
                page.Fragments.Add(loginLabel);
    
                // Create a text field and add it to the field collection.
                TextBoxField loginField = new("Login");
                pdfDocument.Fields.Add(loginField);
    
                // Bind the text field to a widget and place it on the page.
                RectangleF loginBounds = new(120, y - textHeight + 4, 220, textHeight);
                TextBoxWidgetAnnotation loginWidget = new(loginField, loginBounds);
                loginWidget.FontSize = 14;
                page.Annotations.Add(loginWidget);
                y -= step;
    
            }
        }
    }
    

    Implements

    Inheritance

    Object
    FormField
    TextBoxField
    See Also