Fill and Read XFA Forms using C#

Adobe introduced an interactive and dynamic Forms called XFA forms. XFA stands for XML Forms Architecture. XFA form is similar to an HTML file. It contains fillable fields and determines the layout or appearance as a form embedded inside PDF documents. In this article, we will learn how to fill and read XFA forms using C#.

The following topics shall be covered in this article:

C# API to Read and Fill XFA Forms

For working with XFA PDF forms, we will be using Aspose.PDF for .NET API. It allows us to generate, modify, convert, render, secure and print supported documents without using Adobe Acrobat. Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.Pdf

Fill XFA Forms using C#

We can fill XFA forms programmatically by following the steps given below:

  1. Firstly, load an XFA form file using the Document class.
  2. Get names of the loaded XFA form fields.
  3. Set field values.
  4. Finally, call the Save() method. It takes the path of the output file as an argument.

The following code sample shows how to fill an XFA form using C#.

Fill XFA Forms using C#.

Fill XFA Forms using C#.

Read XFA Forms using C#

We can read the filled XFA form by following the steps given below:

  1. Firstly, load an Excel file using the Document class.
  2. Get names of the loaded XFA form fields.
  3. In a loop, get field details using the GetFieldTemplate() method.
  4. Finally, show field attributes.

The following code sample shows how to read the filled XFA form using C#.

Read the filled XFA form using C#.

Read the filled XFA form using C#.

Get a Free License

Please try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, we have learned how to fill the XFA forms without using Adobe writer. We have also seen how to read the filled XFA form programmatically. Besides, you can learn more about Aspose.PDF for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also