问题
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