How can I test if a PDF document is PDF/A compliant using iTextSharp?

后端 未结 1 1617
你的背包
你的背包 2021-01-27 01:01

I have a existing PDF file and with iTextSharp I want to test if it is PDF/A compliant.

I don\'t want convert or create a file, just read and check if it is a PDF/A.

相关标签:
1条回答
  • 2021-01-27 01:43

    After a long search i tried this way and seems to work:

        Dim reader As iTextSharp.text.pdf.PdfReader = New iTextSharp.text.pdf.PdfReader(sFilePdf)
        Dim yMetadata As Byte() = reader.Metadata()
        Dim bPDFA As Boolean = False
    
        If Not yMetadata Is Nothing Then
            Dim sXmlMetadata = System.Text.ASCIIEncoding.Default.GetString(yMetadata)
    
            Dim xmlDoc As Xml.XmlDocument = New Xml.XmlDocument()
            xmlDoc.LoadXml(sXmlMetadata)
            Dim nodes As Xml.XmlNodeList = xmlDoc.GetElementsByTagName("pdfaid:conformance")
            If nodes.Item(0).FirstChild.Value.ToUpper = "A" Then
                bPDFA = True
            End If
        End If
    
        Return bPDFA
    

    I also found some reference to the class XmpReader, but not sufficient to do what I wanted

    0 讨论(0)
提交回复
热议问题