Example #1
0
 /**
  * This will return a list of alternate color spaces(PDColorSpace) if the display application does
  * not support this icc stream.
  *
  * @return A list of alternate color spaces.
  * @throws IOException If there is an error getting the alternate color spaces.
  */
 public List getAlternateColorSpaces() throws IOException {
   COSBase alternate = stream.getDictionaryObject(COSName.getPDFName("Alternate"));
   COSArray alternateArray = null;
   if (alternate == null) {
     alternateArray = new COSArray();
     int numComponents = getNumberOfComponents();
     String csName = null;
     if (numComponents == 1) {
       csName = PDDeviceGray.NAME;
     } else if (numComponents == 3) {
       csName = PDDeviceRGB.NAME;
     } else if (numComponents == 4) {
       csName = PDDeviceCMYK.NAME;
     } else {
       throw new IOException("Unknown colorspace number of components:" + numComponents);
     }
     alternateArray.add(COSName.getPDFName(csName));
   } else {
     if (alternate instanceof COSArray) {
       alternateArray = (COSArray) alternate;
     } else if (alternate instanceof COSName) {
       alternateArray = new COSArray();
       alternateArray.add(alternate);
     } else {
       throw new IOException(
           "Error: expected COSArray or COSName and not " + alternate.getClass().getName());
     }
   }
   List retval = new ArrayList();
   for (int i = 0; i < alternateArray.size(); i++) {
     retval.add(PDColorSpaceFactory.createColorSpace((COSName) alternateArray.get(i)));
   }
   return new COSArrayList(retval, alternateArray);
 }
Example #2
0
  /**
   * This will get the alternate color space for this separation.
   *
   * @return The alternate color space.
   * @throws IOException If there is an error getting the alternate color space.
   */
  public PDColorSpace getAlternateColorSpace() throws IOException {
    COSBase alternate = array.getObject(2);
    PDColorSpace cs = PDColorSpaceFactory.createColorSpace(alternate);

    // logger().info("Returning " + cs.toString() + " for input " + alternate.toString());

    return cs;
  }
Example #3
0
  /**
   * This will get the color space that acts as the index for this color space.
   *
   * @return The base color space.
   * @throws IOException If there is error creating the base color space.
   */
  public PDColorSpace getBaseColorSpace() throws IOException {
    PDColorSpace retval = null;
    COSBase base = array.getObject(1);
    if (base instanceof COSName) {
      retval = PDColorSpaceFactory.createColorSpace((COSName) base);
    } else {
      throw new IOException("Error:unknown base colorspace");
    }

    return retval;
  }