(COSObject) destOutputProfile))) {
// ---- the profile is already checked. continue
return null;
} else if (!mapDestOutputProfile.isEmpty()) {
// ---- A DestOutputProfile exits but it isn't the same, error
return new ValidationError(
ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_MULTIPLE, "More than one ICCProfile is defined");
}
// else the profile will be kept in the tmpDestOutputProfile if it is valid
}
PDStream stream = PDStream.createFromCOS(COSUtils.getAsStream(
destOutputProfile, cDoc));
if (stream == null) {
return new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,
"OutputIntent object uses a NULL Object");
}
ICC_Profile iccp = ICC_Profile.getInstance(stream.getByteArray());
// check the ICC Profile version (6.2.2)
if (iccp.getMajorVersion() == 2) {
if (iccp.getMinorVersion() > 0x40) {
// TODO on lazy mode this error should be a warning?
// in PDF 1.4, max version is 02h.40h (meaning V 3.5)
// see the ICCProfile specification (ICC.1:1998-09)page 13 - §6.1.3 :
// The current profile version number is "2.4.0" (encoded as 02400000h"
return new ValidationError(
ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_TOO_RECENT, "Invalid version of the ICCProfile");
} // else OK
} else if (iccp.getMajorVersion() > 2) {
// TODO on lazy mode this error should be a warning?
// in PDF 1.4, max version is 02h.40h (meaning V 3.5)
// see the ICCProfile specification (ICC.1:1998-09)page 13 - §6.1.3 :
// The current profile version number is "2.4.0" (encoded as 02400000h"
return new ValidationError(
ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_TOO_RECENT, "Invalid version of the ICCProfile");
} // else seems less than 2, so correct
if (handler.getIccProfileWrapper() == null) {
handler.setIccProfileWrapper(new ICCProfileWrapper(iccp));
}
// ---- keep reference to avoid multiple profile definition
mapDestOutputProfile.put(new COSObjectKey((COSObject) destOutputProfile),
true);
} catch (IllegalArgumentException e) {
// ---- this is not a ICC_Profile
return new ValidationError(
ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_INVALID, "DestOutputProfile isn't a ICCProfile");
} catch (IOException e) {
throw new ValidationException("Unable to parse the ICC Profile", e);
}