use of org.apache.pdfbox.pdmodel.graphics.color.PDSeparation in project pdfbox by apache.
the class StandardColorSpaceHelper method processDeviceNColorSpace.
/**
* Method called by the processAllColorSpace if the ColorSpace to check is DeviceN. Because this kind of ColorSpace
* can have alternate color space, the processAllColorSpace is called to check this alternate color space. (There
* are no restrictions on the Alternate Color space)
*
* @param colorSpace
* the color space object to check.
*/
protected void processDeviceNColorSpace(PDColorSpace colorSpace) {
PDDeviceN deviceN = (PDDeviceN) colorSpace;
try {
if (iccpw == null) {
context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_MISSING, "DestOutputProfile is missing"));
return;
}
COSBase cosAlt = ((COSArray) colorSpace.getCOSObject()).getObject(2);
PDColorSpace altColor = PDColorSpace.create(cosAlt);
if (altColor != null) {
processAllColorSpace(altColor);
}
int numberOfColorants = 0;
PDDeviceNAttributes attr = deviceN.getAttributes();
if (attr != null) {
final Map<String, PDSeparation> colorants = attr.getColorants();
if (colorants != null) {
numberOfColorants = colorants.size();
for (PDSeparation col : colorants.values()) {
if (col != null) {
processAllColorSpace(col);
}
}
}
}
int numberOfComponents = deviceN.getNumberOfComponents();
if (numberOfColorants > MAX_DEVICE_N_LIMIT || numberOfComponents > MAX_DEVICE_N_LIMIT) {
context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_TOO_MANY_COMPONENTS_DEVICEN, "DeviceN has too many tint components or colorants"));
}
} catch (IOException e) {
context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read DeviceN color space : " + e.getMessage(), e));
}
}
Aggregations