// ---- a CIDFont is contained in the DescendantFonts array
COSDocument cDoc = this.handler.getDocument().getDocument();
COSArray array = COSUtils.getAsArray(descendantFonts, cDoc);
if (array == null) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_CIDKEYED_INVALID,
"CIDFont is missing from the DescendantFonts array"));
return false;
}
// ---- in PDF 1.4, this array must contain only one element,
// because of a PDF/A should be a PDF 1.4, this method returns an error if
// the array
// has more than one element.
if (array.size() != 1) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_CIDKEYED_INVALID,
"The DescendantFonts array should have one element."));
return false;
}
this.cidFont = COSUtils.getAsDictionary(array.get(0), cDoc);
if (this.cidFont == null) {
this.fontContainer
.addError(new ValidationError(ERROR_FONTS_CIDKEYED_INVALID,
"The DescendantFonts array should have one element with is a dictionary."));
return false;
}
String type = cidFont.getNameAsString(COSName
.getPDFName(DICTIONARY_KEY_TYPE));
String subtype = cidFont.getNameAsString(COSName
.getPDFName(DICTIONARY_KEY_SUBTYPE));
if ((type == null || "".equals(type))
|| (subtype == null || "".equals(subtype))) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID,
"Type and/or Subtype keys are missing"));
return false;
}
boolean isT0 = FONT_DICTIONARY_VALUE_TYPE0.equals(subtype);
boolean isT2 = FONT_DICTIONARY_VALUE_TYPE2.equals(subtype);
// ---- Even if these entries are present, values must be checked.
if (!FONT_DICTIONARY_VALUE_FONT.equals(type) || !(isT0 || isT2)) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID,
"Type and/or Subtype keys are missing"));
return false;
}
// ---- BaseFont is mandatory
String bf = cidFont.getNameAsString(COSName
.getPDFName(FONT_DICTIONARY_KEY_BASEFONT));
if (bf == null || "".equals(bf)) {
this.fontContainer.addError(new ValidationError(
ERROR_FONTS_DICTIONARY_INVALID, "BaseFont is missing"));
return false;
}
// ---- checks others mandatory fields