如何使用iTextSharp测试PDF文档是否符合PDF / A标准? [英] How can I test if a PDF document is PDF/A compliant using iTextSharp?
问题描述
我有一个现有的PDF文件和iTextSharp我想测试它是否符合PDF / A。
I have a existing PDF file and with iTextSharp I want to test if it is PDF/A compliant.
我不想转换或创建文件,只是阅读并检查它是否是PDF / A.
I don't want convert or create a file, just read and check if it is a PDF/A.
我没有尝试任何东西,因为我没有找到iTextSharp类PdfReader的任何方法或属性,说PDF是PDF / 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
谢谢
Antonio
Thanks Antonio
推荐答案
经过长时间的搜索,我尝试了这种方式,似乎有效:
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
我也是找到了一些类XmpReader的引用,但不足以做我想要的事情
I also found some reference to the class XmpReader, but not sufficient to do what I wanted
这篇关于如何使用iTextSharp测试PDF文档是否符合PDF / A标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!