XFA Validation

Hi team,

We are trying to check whether the uploaded pdf document is XFA or not. We added the condition like below in order to achieve this. This code is not allowing other editable documents also to upload. Our requirement is to not allow only XFA documents but this is not accepting other editable documents also. Can you please help us on this.

                   using (PDF.Document document = new PDF.Document(new MemoryStream(insertDocumentDetails.Data)))
                   {
                       // Check for XFA format and throw an exception if found
                       if (document.Form.XFA != null)
                       {
                           return new JsonResult("XFA");
                       }
                   }

@skamalam

Can you please share such PDF documents with us as well? We will test the scenario in our environment and address it accordingly.

I am unable to upload pdfs due to organization restrictions.

Can you please use the below PDF.

@skamalam

Please check below code snippet that we used to detect whether PDF has XFA/Dynamic or Standard AcroForm:

using (Document _pdfDocument = new Document(dataDir + "EDIT OoPdfFormExample.pdf"))
{
    if(_pdfDocument.Form.Type == FormType.Dynamic)
    {
        Console.WriteLine("XFA");
    }
    else
    {
        Console.WriteLine("Acro");
    }
}