return;
}
else if (!mapDestOutputProfile.isEmpty())
{
// A DestOutputProfile exits but it isn't the same, error
addValidationError(ctx, new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_MULTIPLE,
"More than one ICCProfile is defined"));
return;
}
// else the profile will be kept in the tmpDestOutputProfile if it is valid
}
// keep reference to avoid multiple profile definition
mapDestOutputProfile.put(new COSObjectKey((COSObject) destOutputProfile), true);
COSDocument cosDocument = ctx.getDocument().getDocument();
PDStream stream = PDStream.createFromCOS(COSUtils.getAsStream(destOutputProfile, cosDocument));
if (stream == null)
{
addValidationError(ctx, new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY,
"OutputIntent object uses a NULL Object"));
return;
}
ICC_Profile iccp = ICC_Profile.getInstance(stream.getByteArray());
PreflightConfiguration config = ctx.getConfig();
// check the ICC Profile version (6.2.2)
if (iccp.getMajorVersion() == 2)
{
if (iccp.getMinorVersion() > 0x40)
{
// 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")
ValidationError error = new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_TOO_RECENT,
"Invalid version of the ICCProfile");
error.setWarning(config.isLazyValidation());
addValidationError(ctx, error);
return;
} // else OK
}
else if (iccp.getMajorVersion() > 2)
{
// 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"
ValidationError error = new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_TOO_RECENT,
"Invalid version of the ICCProfile");
error.setWarning(config.isLazyValidation());
addValidationError(ctx, error);
return;
} // else seems less than 2, so correct
if (ctx.getIccProfileWrapper() == null)
{
ctx.setIccProfileWrapper(new ICCProfileWrapper(iccp));
}
}
catch (IllegalArgumentException e)
{
// this is not a ICC_Profile
addValidationError(ctx, new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_ICC_PROFILE_INVALID,
"DestOutputProfile isn't a valid ICCProfile. Caused by : " + e.getMessage()));
}
catch (IOException e)
{
throw new ValidationException("Unable to parse the ICC Profile.", e);