Fill Form Fields

This module uses the DevExpress PDF Document API (PdfDocumentProcessor) to populate form fields in a predefined sample file.

Use data editors to specify field values. Click Populate Form and Save to add values to form fields and download the result.

Sample Document
Sample_Form.pdf



using DevExpress.Pdf;
using DevExpress.Drawing;

Stream FillForm(MemoryStream documentStream, string lastName, string firstName,
    string address, string nationality, string passportNumber, string visaNumber,
    string gender, int day, int month, int year, string flightNumber) {
    using var processor = new PdfDocumentProcessor();

    processor.LoadDocument(documentStream);

    var documentFacade = processor.DocumentFacade;
    var form = documentFacade.AcroForm;

    form.GetTextFormField("LastName").Value = lastName;
    form.GetTextFormField("FirstName").Value = firstName;
    form.GetTextFormField("Address").Value = address;
    form.GetComboBoxFormField("Nationality").Value = nationality;
    form.GetTextFormField("PassportNo").Value = passportNumber;
    form.GetTextFormField("VisaNo").Value = visaNumber;
    form.GetRadioGroupFormField("Gender").Value = gender;
    form.GetTextFormField("DD").Value = day.ToString();
    form.GetTextFormField("MM").Value = month.ToString();
    form.GetTextFormField("YYYY").Value = year.ToString();
    form.GetTextFormField("FlightNo").Value = flightNumber;

    var outputStream = new MemoryStream();
    processor.SaveDocument(outputStream);

    outputStream.Position = 0;
    return outputStream;
}