Detect if a PDF file is PDF/A in C#

Spire.PDF provides developers two methods to detect if a PDF file is PDF/A. The one is to use PdfDocument.Conformance property, the other is to use PdfDocument.XmpMetaData property. The following examples demonstrate how we can detect if a PDF file is PDF/A using these two methods.

Below is the screenshot of the sample file we used for demonstration:

Detect if a PDF file is PDF/A in C#

Using PdfDocument.Conformance

using Spire.Pdf;
using System;

namespace Detect
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize a PdfDocument object 
            PdfDocument pdf = new PdfDocument();
            //Load the PDF file
            pdf.LoadFromFile("Example.pdf");

            //Get the conformance level of the PDF file            
            PdfConformanceLevel conformance = pdf.Conformance;
            Console.WriteLine("This PDF file is " + conformance.ToString());
        }
    }
}

Output:

Detect if a PDF file is PDF/A in C#