*/
public static PDFColorSpace getColorSpace(PDFObject csobj, Map resources)
throws IOException {
String name;
PDFObject colorSpaces = null;
if (resources != null) {
colorSpaces = (PDFObject) resources.get("ColorSpace");
}
if (csobj.getType() == PDFObject.NAME) {
name = csobj.getStringValue();
if (name.equals("DeviceGray") || name.equals("G")) {
return getColorSpace(COLORSPACE_GRAY);
} else if (name.equals("DeviceRGB") || name.equals("RGB")) {
return getColorSpace(COLORSPACE_RGB);
} else if (name.equals("DeviceCMYK") || name.equals("CMYK")) {
return getColorSpace(COLORSPACE_CMYK);
} else if (name.equals("Pattern")) {
return getColorSpace(COLORSPACE_PATTERN);
} else if (colorSpaces != null) {
csobj = (PDFObject) colorSpaces.getDictRef(name);
}
}
if (csobj == null) {
return null;