Class ColorUtil


  • public final class ColorUtil
    extends java.lang.Object
    Converts between a PDF colour array (/C//IC: 0, 1, 3 or 4 numeric components -- ISO 32000-1 Table 164/170) and the "#RRGGBB" hex string XFDF's color/interior-color attributes use.

    A 4-component (CMYK) source is converted to its nearest RGB equivalent for display in the hex form -- lossy, but XFDF has no CMYK colour syntax at all, so there's no alternative that stays within the format. A 0-component array (explicitly "no colour", e.g. a transparent annotation border) has no XFDF representation either and is treated the same as a missing/null array: no color attribute is written.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static COSArray toColorArray​(java.lang.String hex)
      null if hex isn't a well-formed "#RRGGBB" string.
      static java.lang.String toHex​(COSArray color)
      null if color is null, empty, or not a numeric-component array of length 1, 3 or 4.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toHex

        public static java.lang.String toHex​(COSArray color)
        null if color is null, empty, or not a numeric-component array of length 1, 3 or 4.
      • toColorArray

        public static COSArray toColorArray​(java.lang.String hex)
        null if hex isn't a well-formed "#RRGGBB" string.