PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Fill XFA form and export XDP data

The following code opens an XFA form and programmatically fills a text field and selects items from drop-down lists and exports the data as XDP.

using (FileStream inFile = new FileStream("Purchase Order.pdf", FileMode.Open, FileAccess.Read))
  // open the source document
  Document document = new Document(inFile);

  TextField textField = document.Fields["form1[0].purchaseOrder[0].header[0].txtOrderedByCompanyName[0]"] 
    as TextField;
  textField.Value = "My Company";

  DropDownListField countryField = document.Fields["form1[0].purchaseOrder[0].header[0].drpOrderedByCountry[0]"] 
    as DropDownListField;
  countryField.DropDownListValue = countryField.Options[1]; // second option ('Canada')

  DropDownListField stateField = document.Fields["form1[0].purchaseOrder[0].header[0].drpOrderedByStateProv[0]"] 
    as DropDownListField;
  stateField.DropDownListValue = stateField.Options[2]; // third option ('Manitoba')

  XdpFormData xdp = document.Export(SubmitFormat.Xdp, false) as XdpFormData;
  xdp.Path = "Purchase Order.pdf";

  using (FileStream xdpFile = new FileStream("Purchase Order_data.xdp", FileMode.Create, FileAccess.Write))
Download PDFKit.NET 5.0
We will send you a download link

  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.