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

我的梦境 提交于 2019-12-20 07:40:03

问题


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.

I have not tried anything because I did not find any methods or properties of the class PdfReader of iTextSharp, saying that the PDF is PDF/A. For now it would be enough to know how to verify that the document claims to be PDF/A compatible

Thanks Antonio


回答1:


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



来源:https://stackoverflow.com/questions/13977379/how-can-i-test-if-a-pdf-document-is-pdf-a-compliant-using-itextsharp

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