private void addSingleMappings(int cidBegin, COSArray arr) { for (int i = 0; i < arr.size().intValue(); i++) { if (!arr.at(i).getType().isNumber()) { LOGGER.log(Level.SEVERE, "W array in CIDFont has invalid entry."); continue; } this.singleMappings.put(Integer.valueOf(cidBegin + i), arr.at(i).getReal()); } }
/** * @return COSObject that is font dictionary for descendant font. */ public COSObject getDescendantFontObject() { if (this.type0FontDict != null) { COSArray array = (COSArray) this.type0FontDict.getKey(ASAtom.DESCENDANT_FONTS).getDirectBase(); if (array != null) { return array.at(0); } } return null; }
private void addLabelsFromArray(COSArray nums) { for (int i = 0; i < nums.size(); i+=2) { COSObject cosKey = nums.at(i); Long key = cosKey == null ? null : cosKey.getInteger(); COSObject cosValue = nums.at(i+1); if (key != null && cosValue != null && !cosValue.empty() && cosValue.getType() == COSObjType.COS_DICT) { PageLabelDictionary pageLabelDictionary = new PageLabelDictionary((COSDictionary) cosValue.getDirectBase(), key.intValue()); this.labelsMap.put(key.intValue(), pageLabelDictionary); } } }
/** * This method calculates object ID for all objects, described in this xref * stream using Index array. */ private void initializeObjIDs() { objIDs = new ArrayList<>(); for (int i = 0; i < index.size() / 2; ++i) { COSInteger firstID = (COSInteger) index.at(2 * i).getDirectBase(); COSInteger lengthOfSubsection = (COSInteger) index.at(2 * i + 1).getDirectBase(); for (int j = 0; j < lengthOfSubsection.get(); ++j) { objIDs.add(firstID.get() + j); } } }
private Double getRequiredValue(final int position) { COSArray array = (COSArray) this.baseObject; if (array.size().intValue() > position) { COSBase base = array.at(position).get(); if (base instanceof COSNumber) { return base.getReal(); } LOGGER.log(Level.WARNING, "In bbox expected number but got " + base.getClass().getSimpleName()); } else { LOGGER.log(Level.WARNING, "Expected size of bbox array greater than" + position + "but got " + array.size()); } return null; }
private static COSDictionary getDescendantCOSDictionary(COSDictionary dict) { if (dict != null) { COSArray array = (COSArray) dict.getKey(ASAtom.DESCENDANT_FONTS).getDirectBase(); if (array != null) { return (COSDictionary) array.at(0).getDirectBase(); } } return null; }
/** * Constructor from a COSObject. * * @param w is W array from CIDFont dictionary. */ public CIDWArray(COSArray w) { singleMappings = new HashMap<>(); ranges = new ArrayList<>(); if (w != null) { for (int i = 0; i < w.size().intValue(); ++i) { int cidBegin = w.at(i++).getInteger().intValue(); COSObject obj = w.at(i); if (obj.getType() == COSObjType.COS_INTEGER) { int cidEnd = obj.getInteger().intValue(); Double width = w.at(++i).getReal(); if (width == null) { LOGGER.log(Level.FINE, "Unexpected end of W array in CID font"); return; } this.ranges.add(new CIDWArrayRange(cidBegin, cidEnd, width.doubleValue())); } else if (obj.getType() == COSObjType.COS_ARRAY) { addSingleMappings(cidBegin, (COSArray) obj.getDirectBase()); } } } }
private static double[] getDoubleArrayForBox(COSArray array) { if (array == null) { return null; } double[] res = new double[4]; for (int i = 0; i < array.size(); ++i) { COSObject obj = array.at(i); if (obj.getType().isNumber()) { res[i] = obj.getReal().doubleValue(); } else { res[i] = 0; } } return res; }
public void visitFromArray(COSArray obj) { try { this.write("["); for (int i = 0; i < obj.size(); i++) { this.write(obj.at(i)); this.write(" "); } this.write("]"); } catch (IOException e) { e.printStackTrace(); } }
/** * @return int[] representation of ByteRange entry. */ public int[] getByteRange() { COSObject cosByteRange = this.getKey(ASAtom.BYTERANGE); if (cosByteRange.getType() == COSObjType.COS_ARRAY) { COSArray array = (COSArray) cosByteRange.getDirectBase(); if (array.size() >= 4) { int[] res = new int[4]; for (int i = 0; i < 4; ++i) { res[i] = array.at(i).getInteger().intValue(); } return res; } } return null; }
public void visitFromArray(COSArray obj) { this.copy.assign(COSArray.construct()); for (int i = 0; i < obj.size(); ++i) { COSObject element = new COSObject(); COSCopier copier = new COSCopier(element); obj.at(i).accept(copier); this.copy.add(element); } }
private static boolean baseCheck(TransparencyGraphicsState graphicState) { COSObject sMask = graphicState.getSMask(); if (sMask != null && sMask.getType().isDictionaryBased()) { return true; } COSObject bm = graphicState.getBm(); if (bm != null) { if (bm.getType() == COSObjType.COS_NAME) { if (!ASAtom.NORMAL.equals(bm.getName())) { return true; } } else if (bm.getType() == COSObjType.COS_ARRAY) { COSArray bmArray = (COSArray) bm.getDirectBase(); if (bmArray.size().intValue() != 1) { return true; } COSObject bmValue = bmArray.at(0); if (bmValue == null || bmValue.getType() != COSObjType.COS_NAME || ASAtom.NORMAL.equals(bmValue.getName())) { return true; } } else { return !bm.empty() && bm.getType() != COSObjType.COS_NULL; } } return false; }
COSObject base = array.at(number); idAlt = getId(base, FeatureObjectType.COLORSPACE); PDColorSpace alternate = ColorSpaceFactory.getColorSpace(base);