private static PDColorSpace getColorSpaceFromArray(COSObject base) { if (base.size() < 2) { LOGGER.debug("ColorSpace array can not contain less than two elements"); return null; } ASAtom name = base.at(0).getName(); if (ASAtom.CALGRAY.equals(name)) { return new PDCalGray(base.at(1)); } else if (ASAtom.CALRGB.equals(name)) { return new PDCalRGB(base.at(1)); } else if (ASAtom.LAB.equals(name)) { return new PDLab(base.at(1)); } else if (ASAtom.ICCBASED.equals(name)) { return new PDICCBased(base.at(1)); } else if (ASAtom.SEPARATION.equals(name)) { return new PDSeparation(base.at(1), ColorSpaceFactory.getColorSpace(base.at(2)), base.at(3)); } else if (ASAtom.DEVICEN.equals(name)) { return new PDDeviceN( getListOfNames(base.at(1)), ColorSpaceFactory.getColorSpace(base.at(2)), base.at(3), base.at(4)); } else if (ASAtom.INDEXED.equals(name)) { return new PDIndexed( ColorSpaceFactory.getColorSpace(base.at(1)), base.at(2).getInteger(), getLookup(base.at(3))); } else { LOGGER.debug("Unknown ColorSpace name"); return null; } }
private static List<COSObject> getListOfNames(COSObject object) { if (object.getType() == COSObjType.COS_ARRAY) { List<COSObject> names = new ArrayList<>(); for (int i = 0; i < object.size(); ++i) { names.add(object.at(i)); } } return null; }