Class ColorSpace

    • Method Detail

      • createProcessColorSpace

        public static ColorSpace createProcessColorSpace​(Document targetDocument,
                                                         ProcessColorSpaceType type)
                                                  throws java.io.IOException

        Get the canonical grayscale, RGB, or CMYK color space.

        Depending on the PDF/A compliance and the output intent, this is either a device color space (DeviceGrayColorSpace, DeviceRgbColorSpace, DeviceCmykColorSpace), a calibrated color space (CalibratedGrayColorSpace, CalibratedRgbColorSpace), or an ICC-based color space (4-channel IccBasedColorSpace). The returned color space object is not yet used on any page, but it is associated with the given target document.
        Parameters:
        targetDocument - the output document with which the returned object is associated
        type - the color space type
        Returns:
        newly created color space object
        Throws:
        java.io.IOException - Unable to read a required ICC profile or writing to the document
        java.lang.IllegalArgumentException - if the targetDocument argument has already been closed
        java.lang.IllegalArgumentException - if the targetDocument argument is read-only
        java.lang.IllegalArgumentException - if targetDocument is null
        java.lang.IllegalArgumentException - if type is null
      • copy

        public static ColorSpace copy​(Document targetDocument,
                                      ColorSpace colorSpace)
                               throws java.io.IOException,
                                      CorruptException,
                                      ConformanceException

        Copy a color space

        Copy a color space object from an input document to the given targetDocument. The returned object is associated with the given target document but not yet part of it.
        Parameters:
        targetDocument - the output document with which the returned object is associated
        colorSpace - a color space of a different document
        Returns:
        the copied color space, associated with the current document.
        Throws:
        java.io.IOException - Error reading from the source document or writing to the target document
        CorruptException - The source document is corrupt
        ConformanceException - The conformance level of the source document is not compatible with the conformance level of the target document.
        java.lang.IllegalArgumentException - if the targetDocument argument has already been closed
        java.lang.IllegalArgumentException - if the targetDocument argument is read-only
        java.lang.IllegalArgumentException - if the colorSpace object is not associated with an input document
        java.lang.IllegalArgumentException - if the colorSpace object has already been closed
        java.lang.IllegalArgumentException - if targetDocument is null
        java.lang.IllegalArgumentException - if colorSpace is null
      • getComponentCount

        public int getComponentCount()

        the number of components in the color space. (Getter)

        Throws:
        java.lang.IllegalStateException - if the color space has already been closed