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

扶醉桌前 提交于 2019-12-02 10:04:21

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!