/** * @return last char in the font as specified in LastChar key of font * dictionary. */ public Long getLastChar() { return this.dictionary.getIntegerKey(ASAtom.LAST_CHAR); }
/** * @return first char in the font as specified in FirstChar key of font * dictionary. */ public Long getFirstChar() { return this.dictionary.getIntegerKey(ASAtom.FIRST_CHAR); }
private static int colorsFromParams(COSDictionary decodeParams) { if (decodeParams.knownKey(ASAtom.COLORS)) { return decodeParams.getIntegerKey(ASAtom.COLORS).intValue(); } else { return COLORS_DEFAULT; } }
private static int columnsFromParams(COSDictionary decodeParams) { if (decodeParams.knownKey(ASAtom.COLUMNS)) { return decodeParams.getIntegerKey(ASAtom.COLUMNS).intValue(); } else { return COLUMNS_DEFAULT; } }
private static byte predictorFromParams(COSDictionary decodeParams) { if (decodeParams.knownKey(ASAtom.PREDICTOR)) { return (byte) decodeParams.getIntegerKey(ASAtom.PREDICTOR).intValue(); } else { return PREDICTOR_DEFAULT; } }
private static int bitsFromParams(COSDictionary decodeParams) { if (decodeParams.knownKey(ASAtom.BITS_PER_COMPONENT)) { return decodeParams.getIntegerKey(ASAtom.BITS_PER_COMPONENT).intValue(); } else { return BITS_PER_COMPONENT_DEFAULT; } }
public PageLabelDictionary(COSDictionary dict, int rangeStartIndex) { this.type = dict.getNameKey(ASAtom.S); String prefixValue = dict.getStringKey(ASAtom.P); this.prefix = prefixValue == null ? "" : prefixValue; Long integerKey = dict.getIntegerKey(ASAtom.ST); this.firstRangePortion = integerKey == null ? 1 : integerKey.intValue(); this.rangeStartIndex = rangeStartIndex; }
/** * @return Supplement value from CMap CIDSystemInfo dictionary. */ public Long getSupplement() { if (this.getCIDSystemInfo() == null) { return null; } return this.getCIDSystemInfo().getIntegerKey(ASAtom.SUPPLEMENT); }
/** * Constructor from LZW encoded data stream and decode parameters * dictionary. * * @param stream is LZW encoded data. * @param decodeParams is decode parameters dictionary. */ public COSFilterLZWDecode(ASInputStream stream, COSDictionary decodeParams) throws IOException { super(stream); Long earlyChangeFromDecodeParams = decodeParams.getIntegerKey(ASAtom.EARLY_CHANGE); // 0 and 1 are only possible values. // In other cases we use default value 1. if (earlyChangeFromDecodeParams == null || earlyChangeFromDecodeParams.intValue() != 0) { this.earlyChange = 1; } else { this.earlyChange = 0; } this.bitStream = new MemoryCacheImageInputStream(stream); initLZWTable(); }
/** * Gets width for glyph with given code in this font. * * @param code is code of glyph. * @return width for glyph with given code as specified in Widths array. */ public Double getWidth(int code) { if (dictionary.knownKey(ASAtom.WIDTHS).booleanValue() && dictionary.knownKey(ASAtom.FIRST_CHAR).booleanValue() && dictionary.knownKey(ASAtom.LAST_CHAR).booleanValue()) { int firstChar = dictionary.getIntegerKey(ASAtom.FIRST_CHAR).intValue(); int lastChar = dictionary.getIntegerKey(ASAtom.LAST_CHAR).intValue(); if (getWidths().size().intValue() > 0 && code >= firstChar && code <= lastChar) { return getWidths().at(code - firstChar).getReal(); } } if (fontDescriptor.knownKey(ASAtom.MISSING_WIDTH)) { return fontDescriptor.getMissingWidth(); } if (this instanceof PDType3Font) { return null; } return Double.valueOf(0); }
private ASInputStream readInlineImage() throws IOException { source.resetReadCounter(); ArrayList<Byte> image = new ArrayList<>(INLINE_IMAGE_BUFFER_SIZE); byte previousByte = source.readByte(); byte currentByte = source.readByte(); image.add(previousByte); image.add(currentByte); Long l = this.lastInlineImageDict == null ? new Long(0) : lastInlineImageDict.getIntegerKey(ASAtom.L); if (l == null) { l = lastInlineImageDict.getIntegerKey(ASAtom.LENGTH); } while (!(this.source.isEOF())) { if (previousByte == 'E' && currentByte == 'I' && isSourceAfterImage(l)) { break; } previousByte = currentByte; currentByte = source.readByte(); image.add(currentByte); } return new ASMemoryInStream(getByteArrayFromArrayList(image), source.getReadCounter(), false); }