/// <summary>
        /// Init
        /// </summary>
        public void Init(PdfResources resourcesDict)
        {
            colorSpaces = new Dictionary <string, IColorSpace>();

            IColorSpace predefinedColorSpace = new RGBDeviceColorSpace();

            colorSpaces.Add(PdfKeys.DeviceRGB, predefinedColorSpace);

            predefinedColorSpace = new CMYKDeviceColorSpace();
            colorSpaces.Add(PdfKeys.DeviceCMYK, predefinedColorSpace);

            predefinedColorSpace = new GrayDeviceColorSpace();
            colorSpaces.Add(PdfKeys.DeviceGray, predefinedColorSpace);

            var predefinedColorSpacePattern = new PatternColorSpace(patternManager);

            colorSpaces.Add(PdfKeys.DevicePattern, predefinedColorSpacePattern);

            if (resourcesDict != null)
            {
                ReadResourceDefinedColorSpaces(resourcesDict);
            }
        }
        /// <summary>
        /// Get one color space
        /// </summary>
        public static IColorSpace CreateColorSpace(string colorSpaceName, PdfArray colorSpaceArray)
        {
            IColorSpace colorSpace = null;

            switch (colorSpaceName)
            {
            case PdfKeys.DefaultRGB:
            case PdfKeys.DeviceRGB:
            {
                colorSpace = new RGBDeviceColorSpace();
                break;
            }

            case PdfKeys.DefaultCMYK:
            case PdfKeys.DeviceCMYK:
            {
                colorSpace = new CMYKDeviceColorSpace();
                break;
            }

            case PdfKeys.DefaultGray:
            case PdfKeys.DeviceGray:
            {
                colorSpace = new GrayDeviceColorSpace();
                break;
            }

            case PdfKeys.ICCBased:
            {
                colorSpace = new ICCBasedColorSpace();
                break;
            }

            case PdfKeys.Indexed:
            {
                colorSpace = new IndexedColorSpace();
                break;
            }

            case PdfKeys.DeviceN:
            {
                colorSpace = new DeviceNColorSpace();
                break;
            }

            case PdfKeys.CalGray:
            {
                colorSpace = new UnknownColorSpace(1);
                break;
            }

            case PdfKeys.CalRGB:
            {
                colorSpace = new UnknownColorSpace(3);
                break;
            }

            case PdfKeys.Lab:
            {
                colorSpace = new UnknownColorSpace(3);
                break;
            }

            default:
            {
                colorSpace = new UnknownColorSpace(1);
                break;
            }
            }

            colorSpace.Init(colorSpaceArray);

            return(colorSpace);
        }