We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How can I determine if a PDF has XFA in it?

Well, that is about it. When our app gets a pdf, I'd like to be able to check if it has XFA forms within it. How can I do that?


  PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(filePath); 
            //Get the loaded XFA form. 
            PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm; 

but .XfaForm nolonger seems to be valid.

Thanks!

4 Replies

SK Surya Kumar Syncfusion Team July 8, 2019 12:22 PM UTC

Hi Will, 

Greetings from Syncfusion. 

At present we do not have support for determining if the PDF document is XFA enabled, but we have support for filling XFA form fields along with Acroform in the same API. Documentation link for the same can be found in below link: 
UG link : 

Could you please let us know what is your exact need for identifying XFA form documents so that we can assist you better. 

Regards, 
Surya Kumar 



SB Scott Barber March 8, 2021 12:37 AM UTC

Hi there, we have recently found ourselves in this situation.

We have a solution which flattens PDFs which are uploaded from users system. Unfortunately it's possible that the user can upload an XFA form. We would like to be able to detect if it is of this type so we can call the flatten XFA function.

Thanks!


SL Sowmiya Loganathan Syncfusion Team March 8, 2021 12:09 PM UTC

Hi Scott,   

We have analyzed your requirement “Detect XFA form in the given PDF document” and at present we do not have support for this. Currently we are validating on this and will update the further details on March 10, 2021.   

Regards,  
Sowmiya Loganathan 



SL Sowmiya Loganathan Syncfusion Team March 10, 2021 03:12 PM UTC

Hi Will,  
 
On our further analysis ,we can able find the document contains XFAForm or not in sample level using below workaround. 
Please refer the below code snippet, 
        private bool IsXFADocument(string filePath) 
        { 
            bool isXfa = false; 
 
            PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(filePath); 
            //Get the loaded XFA form.  
 
            PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm; 
 
            int count = loadedForm.Fields.Count; 
 
            loadedDocument.Close(); 
            //If the loaded field count is greater than zero then its a XFA document.  
            if (count > 0) 
                isXfa = true; 
            return isXfa;        
        }  
 
Kindly try the above solution in your end and Let us know, if you need any further information in this. 
 
Regards, 
Sowmiya Loganathan 


Loader.
Live Chat Icon For mobile
Up arrow icon