Class OutputProfiler.ProcessColorAction

    • Constructor Detail

      • ProcessColorAction

        public ProcessColorAction​(OutputProfile target)

        Create a new ProcessColorAction that will convert colors in the PDF to try and match the OutputProfile and its main OutputIntent.

        Here's an example showing how to use this constructor to simplify conversion of a PDF to a PDF/A document with all uncalibrated colors converted to the Output Intent specifed in the profile.

         OutputProfiler profiler = new OutputProfiler(new PDFParser(pdf));
         OutputProfile profile = profiler.getProfile();
        
         ColorSpace icc = new ICCColorSpace("US_Web_Coated_SWOP.icm");
         OutputProfile target = new OutputProfile(OutputProfile.PDFA1b_2005);
         target.getOutputIntents().add(new OutputIntent("GTS_PDFA1", "CGATS TR 001", icc));
         profiler.setColorAction(new OutputProfiler.ProcessColorAction(target));
         profiler.apply(target);
         

        Note: if the target has a CMYK OutputIntent, this constructor will also set setRemapNamedInks(boolean) to true

        Parameters:
        target - the OutputProfile to match and retrieve the OutputIntent from - typically a PDF/A or PDF/X profile.
        See Also:
        OutputProfile.getOutputIntents(), OutputIntent.getColorSpace()
    • Method Detail

      • setAllowCalibrated

        public void setAllowCalibrated​(boolean flag)
        Determines how process colors in a calibrated ColorSpace are modified. If true, calibrated colors are allowed and will remain unchanged, but device-dependent colors will be changed to the specified process ColorSpace (appropriate for PDF/A and PDF/X-3). If false, calibrated colors are disallowed and will be converted as well (appropriate for PDF/X-1). The default is true.
        Parameters:
        flag - whether calibrated process colors should remain unchanged
      • setRemapNamedInks

        public void setRemapNamedInks​(boolean flag)
        When the input color is a Spot or DeviceN color and the input color needs to change, we can either remap the Spot/DeviceN color to a color in the destination process ColorSpace (set to true), or we can discard the Spot/DeviceN colorspace and replace it with the process color equivalent (set to false: the default).
        Parameters:
        flag - whether Spot or DeviceN inks should be modified or replaced with process equivalents
        Since:
        2.23.2
      • getRemapNamedInks

        public boolean getRemapNamedInks()
        Return the value of the flag set by setRemapNamedInks(boolean)
        Since:
        2.26
      • setUseDefaultColorSpaces

        public void setUseDefaultColorSpaces​(boolean flag)
        When the input color is a device color and the API needs to make it calibrated, the default method is to modify the color in the object itself. An alternative method is to use the PDFPage.setDefaultColorSpace(int, java.awt.color.ColorSpace) method to set the appropriate "Default" colorspaces on the page/canvas etc. - this method controls whether that approach is selected.
        Parameters:
        flag - whether the corrections should be made using the Default colorspaces
        Since:
        2.26
      • setRenderingIntent

        public void setRenderingIntent​(OutputProfiler.RenderingIntent intent)
        Set the rendering intent, to control how out-of-gamut colors are converted. The default is Perceptual, and other values may not be supported depending on the ColorSpace. If not, the process will fall back to Perceptual
        Parameters:
        intent - the rendering intent for color conversion
      • changeColor

        public ColorSpace changeColor​(OutputProfiler profiler,
                                      ColorSpace csin,
                                      float[] src,
                                      float[] dst,
                                      boolean fill,
                                      int type)
        Description copied from interface: OutputProfiler.ColorAction

        Optionally converts a Color from one ColorSpace to another.

        If the source Color is to be converted, this method should return the ColorSpace it will be converted to, and populate the dst array with the new color components if dst is not null. If dst is null, it is sufficient to just return the target ColorSpace (which may be the same as the source ColorSpace, for example if the Colors are simply being retinted).

        If no change is to be made, this method should return null. If "dst" is not null and this method returns null, subsequent calls to changeColor will be skipped. This optimization can be used when the ColorSpace of an image has been changed, but the components remain identical.

        This method must be consistent and return the same output for the same input parameters. It must also be quick, as it may be called millions of times during preflighting (as it must be called once for each pixel).

        Specified by:
        changeColor in interface OutputProfiler.ColorAction
        Parameters:
        profiler - the OutputProfiler this action is being run on
        csin - the source ColorSpace
        src - the source Color components
        dst - if not null, should be updated with the target Color components
        fill - true if the Color will be used for filling, false if for stroking
        type - the type of ColorSpace, which will be a bitmask possibly including one or more of #TYPE_PROCESS, #TYPE_CALIBRATED, #TYPE_SEPARATION, #TYPE_SHADING or #TYPE_BITMAP
        Returns:
        the target ColorSpace or null for no change.
      • setColorSpaces

        public void setColorSpaces​(Collection<? extends ColorSpace> cslist)
        Set a list of ColorSpace objects which may be used by the OutputProfiler.apply(org.faceless.pdf2.OutputProfile) method to to map a Device colorspace to a non-device ColorSpace. The supplied collection may contain ICC_ColorSpace or ICCColorSpace objects, which may be grayscale, RGB or CMYK (others will be ignored). The first matching ColorSpace for each of these categories is used, where required, to "anchor" colors in the corresponding Device ColorSpace to a calibrated ColorSpace.
        Parameters:
        cslist - a collection of 0 or more ColorSpaces. A null value is the same as an empty list.
        Since:
        2.26
      • getUsedIntentColorSpace

        public ColorSpace getUsedIntentColorSpace()
        Return the ColorSpace which was extracted from the OutputProfile supplied to the constructor, if any, that serves as the "intent" ColorSpace around which the algorithm used by this class is based.
        Specified by:
        getUsedIntentColorSpace in interface OutputProfiler.ColorAction
        Since:
        2.26