I had a function written using iText v5 and I'm trying to update it to use iText v7. The function checks if a document claims to be PDF/A (I know iText is not a PDF/A Validatior, I just need to know if it declares to be).
The implementation in v5 is the one from this other question. However, reader.getMetadata() method is no longer available in iText v7.
I've found that the reader in v7 provides a new method that looks perfect for that situation getPdfAConformanceLevel, but it is returning always null. After checking the source code I don't see where pdfAConformanceLevel is initialized, so I wonder, how does this work?
I've tried also reading the DocumentInformation, but without sucess.
My code is:
PdfReader reader = new PdfReader(file);
PdfAConformanceLevel level = reader.getPdfAConformanceLevel();
if (level != null) {
String conformance = level.getConformance();
return "A".equalsIgnoreCase(conformance) || "B".equalsIgnoreCase(conformance);
}
return false