Skip to Content

How do I know if a PDF document is a forms file?

Estimated Reading Time: < 1 Minute

Use this code to programmatically determine if a PDF document is an AcroForm:

bool hasAcroFormFields = false;
if(doc.Root.Contains("AcroForm"))
{
var AcroFormDict = doc.Root.Get("AcroForm") as PDFDict;
hasAcroFormFields = AcroFormDict.Contains("Fields") && (AcroFormDict.Get("Fields") as PDFArray).Length > 0;
}
if (hasAcroFormFields)
Console.WriteLine("Has AcroForm Fields: {0}", filename);


This code identifies the API calls that you can use to detect an AcroForm PDF document. It is not designed to detect XFA forms.

 

How do I know if a PDF document is a forms file?
  • COMMENT