List of usage examples for org.apache.pdfbox.pdmodel.graphics.color PDICCBased getPDStream
public PDStream getPDStream()
From source file:org.apache.padaf.preflight.graphics.color.StandardColorSpaceHelper.java
License:Apache License
/** * Method called by the processAllColorSpace if the ColorSpace to check is a * ICCBased color space. Because this kind of ColorSpace can have alternate * color space, the processAllColorSpace is called to check this alternate * color space. (Pattern is forbidden as Alternate Color Space) * // w w w .j a va 2 s . c om * @param pdcs * the color space object to check. * @param result * the list of error to update if the validation fails. * @return true if the color space is valid, false otherwise. */ protected boolean processICCBasedColorSpace(PDColorSpace pdcs, List<ValidationError> result) { PDICCBased iccBased = (PDICCBased) pdcs; try { ICC_Profile iccp = ICC_Profile.getInstance(iccBased.getPDStream().getByteArray()); if (iccp == null) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE_ICCBASED, "Unable to read ICCBase color space ")); return false; } List<PDColorSpace> altCs = iccBased.getAlternateColorSpaces(); for (PDColorSpace altpdcs : altCs) { if (altpdcs != null) { ColorSpaces altCsId = ColorSpaces.valueOf(altpdcs.getName()); if (altCsId == ColorSpaces.Pattern) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_PATTERN_COLOR_SPACE_FORBIDDEN, "Pattern is forbidden as AlternateColorSpace of a ICCBased")); return false; } /* * According to the ISO-19005-1:2005 * * A conforming reader shall render ICCBased colour spaces as specified * by the ICC specification, and shall not use the Alternate colour space * specified in an ICC profile stream dictionary * * We don't check the alternate ColorSpaces */ } } } catch (IOException e) { result.add(new ValidationError(ERROR_GRAPHIC_INVALID_COLOR_SPACE, "Unable to read ICCBase color space : " + e.getMessage())); return false; } return true; }