public ASInputStream getData() { return getData(COSStream.FilterFlags.RAW_DATA); }
@Override public InputStream getData() { return this.cosEmbFile == null || this.cosEmbFile.empty() ? null : this.cosEmbFile.getData(COSStream.FilterFlags.DECODE); }
public ASInputStream getData(final COSStream.FilterFlags flags) { return getDirect().getData(flags); }
public static COSObject concatenateStreams(COSArray streams) throws IOException { List<ASInputStream> resList = new ArrayList<>(); for (COSObject stream : streams) { if (stream.getType() == COSObjType.COS_STREAM) { ASInputStream streamData = stream.getData(FilterFlags.DECODE); resList.add(streamData); } } ASInputStream[] asInputStreams = resList.toArray(new ASInputStream[resList.size()]); ASInputStream inputContentStream = new ASConcatenatedInputStream(asInputStreams); return COSStream.construct(inputContentStream); } }
@Override public InputStream getData() { if (profile != null && !profile.empty()) { return profile.getObject().getData(COSStream.FilterFlags.DECODE); } return null; }
@Override public InputStream getRawStreamData() { if (imageXObject != null && !imageXObject.empty()) { return imageXObject.getObject().getData(); } return null; }
@Override public InputStream getJBIG2Global() { COSObject globals = base.getKey(ASAtom.JBIG2_GLOBALS); if (globals.getType() == COSObjType.COS_STREAM) { return globals.getData(COSStream.FilterFlags.DECODE); } return null; }
private void initializeProfileHeader() { try (ASInputStream data = this.getObject().getData(COSStream.FilterFlags.DECODE)) { byte[] temp = new byte[HEADER_LENGTH]; int count = Math.max(data.read(temp, HEADER_LENGTH), 0); if (count == HEADER_LENGTH) { this.profileHeader = temp; } else { this.profileHeader = Arrays.copyOf(temp, count); } this.creationDate = parseCreationDate(this.profileHeader); if (this.profileHeader.length != HEADER_LENGTH) { this.isLooksValid = false; } parseTags(data); } catch (IOException e) { this.isLooksValid = false; LOGGER.log(Level.FINE, "Exception during obtaining ICCProfile header", e); } }
public ASInputStream getLookup() { COSObject object = getObject().at(3); if (object != null) { COSObjType type = object.getType(); if (type == COSObjType.COS_STRING) { return new ASMemoryInStream(object.getString().getBytes()); } else if (type == COSObjType.COS_STREAM) { return object.getData(COSStream.FilterFlags.DECODE); } } return null; }
@Override public float getWidthFromProgram(int code) { COSObject charProc = getCharProc(code); if (charProc.getType() == COSObjType.COS_STREAM) { try (Type3CharProcParser parser = new Type3CharProcParser(charProc.getData(COSStream.FilterFlags.DECODE))) { parser.parse(); return (float) parser.getWidth(); } catch (IOException e) { LOGGER.log(Level.FINE, "Can't get width from type 3 char proc", e); } } return -1; }
/** * Constructor from COSObject, containing CIDToGID. * * @param obj is COSObject, obtained via key CIDToGIDMap in CIDFontType2 dict. */ public CIDToGIDMapping(COSObject obj) throws IOException { if (obj != null && (obj.getType() == COSObjType.COS_STREAM || obj.getType() == COSObjType.COS_NAME)) { if (obj.getType() == COSObjType.COS_NAME && obj.getName() == ASAtom.IDENTITY) { this.isIdentity = true; this.mapping = new int[0]; return; } else { this.isIdentity = false; try (ASInputStream stream = obj.getData(COSStream.FilterFlags.DECODE)) { mapping = new int[(obj.getIntegerKey(ASAtom.LENGTH).intValue() + 1) / 2]; parseCIDToGIDStream(stream); } return; } } this.isIdentity = true; // Default value. this.mapping = new int[0]; }
private void init() { if (profile != null && !profile.empty()) { try (ASInputStream iccData = profile.getObject().getData(COSStream.FilterFlags.DECODE)) { errors = new ArrayList<>(); byte[] profileBytes = GFAdapterHelper.inputStreamToByteArray(iccData); if (profileBytes.length < HEADER_SIZE) { errors.add("ICCProfile contains less than " + HEADER_SIZE + " bytes"); } else { this.version = getVersion(profileBytes); this.cmmType = profile.getCMMType(); this.dataColorSpace = profile.getColorSpace(); this.creator = profile.getCreator(); this.creationDate = profile.getCreationDate(); this.defaultRenderingIntent = profile.getRenderingIntent(); this.copyright = profile.getCopyright(); this.description = profile.getDescription(); this.profileID = profile.getProfileID(); this.deviceModel = profile.getDeviceModel(); this.deviceManufacturer = profile.getDeviceManufacturer(); } } catch (IOException e) { LOGGER.log(Level.FINE, "Reading byte array from InputStream error", e); errors.add(e.getMessage()); } } }
private void parseJPXAndColorSpace() { List<ASAtom> filters = getFilters(); if (filters.contains(ASAtom.JPX_DECODE)) { this.jpxStream = JPEG2000.fromStream(getObject().getData()); this.imageCS = this.imageCS == null ? this.jpxStream.getImageColorSpace() : this.imageCS; } COSObject rawColorSpace = getKey(ASAtom.COLORSPACE); if (rawColorSpace != null && !rawColorSpace.empty() && rawColorSpace.getType() != COSObjType.COS_NULL) { if (rawColorSpace.getType() == COSObjType.COS_NAME) { this.colorSpaceName = rawColorSpace.getName(); } if (rawColorSpace.getType() == COSObjType.COS_ARRAY) { this.imageCS = ColorSpaceFactory.getColorSpace(rawColorSpace, resources); } } }
parsedCMap = true; if (this.getObject().getType() == COSObjType.COS_STREAM) { try (ASInputStream cMapStream = this.getObject().getData(COSStream.FilterFlags.DECODE)) { this.cMapFile = CMapFactory.getCMap(getCMapID(), cMapStream); } catch (IOException e) {