ImageGear .NET - Updated
XFA Support
User Guide > How to Work with... > PDF > How to... > Work with PDF Forms > XFA Support

ImageGear for .NET has limited support for PDF documents containing XFA forms.

Enabling XFA

By default, loading a PDF document that contains XFA data will throw an exception and the document will not be loaded since special consideration is needed on how to treat such a document (see below).

In order to enable opening of PDF documents containing XFA data, you have to set the corresponding control parameter XFAAllowed to true:

C#
Copy Code
IImGearFormat format = ImGearFileFormats.Filters.Get(ImGearFormats.PDF);
format.Parameters.GetByName("XFAAllowed").Value = true;

Rendering XFA

PDF documents containing XFA come in different flavors: dynamic and static. Currently, ImageGear for .NET does not support rendering of dynamic XFA content. Usually, a placeholder page with a warning message that is present in the document will be rendered instead. Documents containing static XFA will usually render correctly since the XFA information is duplicated in the PDF as Acroform fields and/or content, and XFA data is simply ignored.

Modifying Forms

Since XFA data is currently largely ignored by ImageGear .NET, changing form fields by means of the ImGearPDFDocument.Form and related objects will not update the XFA data, and these will become out of sync with the Acroforms data. Fields and their widgets should therefore not be added, removed, modified, flattened or filled in.

The only valid operation on a form when XFA is present is the flattening of the whole form using ImGearPDFDocument.FlattenFormFields(). This will flatten any Acroform fields and remove the Form, including any XFA data.

Detecting and Removing XFA

ImageGear for .NET allows you to determine whether a document has XFA and also whether it is dynamic or static, using the property ImGearPDFDocument.XFAContentType. Complete removal of the XFA data can be done using the method ImGearPDFDocument.RemoveXFA(). This will not change any Acroform data.