New to Telerik Document ProcessingStart a free 30-day trial

Iterate and modify form fields in code

Updated on Feb 19, 2026
Product VersionProductAuthor
2020.1.218RadPdfProcessingDimitar Karamfilov

Description

You have a document that has many form fields and you want to populate them with data in the code.

Solution

You can import the document and iterate all fields. This will allow you to set their value.

csharp

    var provider = new PdfFormatProvider();

    var document = provider.Import(File.ReadAllBytes("form_doc.pdf"));

    foreach (RadFixedPage page in document.Pages)
    {
        
        foreach (Annotation annotation in page.Annotations)
        {
            if (annotation.Type == AnnotationType.Widget)
            {
                Widget widget = (Widget)annotation;
                var field = widget.Field as TextBoxField;
                if (field != null)
                {
                    if (field.Name == "Name")
                    {
                        field.Value = "John Doe";
                    }
                }
            }
        }
    }

    File.WriteAllBytes("result.pdf", provider.Export(document));
In this article
DescriptionSolution
Not finding the help you need?
Contact Support