/** * Tells you if the node contains a stream. * * @return true if the object is a PRStream */ public boolean isStream() { return object.isStream(); }
private static CMapEncoding createCMap(PdfObject cmap, String uniMap) { if (cmap.isStream()) { PdfStream cmapStream = (PdfStream) cmap; byte[] cmapBytes = cmapStream.getBytes(); return new CMapEncoding(cmapStream.getAsName(PdfName.CMapName).getValue(), cmapBytes); } else { String cmapName = ((PdfName) cmap).getValue(); if (PdfEncodings.IDENTITY_H.equals(cmapName) || PdfEncodings.IDENTITY_V.equals(cmapName)) { return new CMapEncoding(cmapName); } else { return new CMapEncoding(cmapName, uniMap); } } }
public SerializedObjectContent serializeObject(PdfObject obj) { if (!obj.isStream() && !obj.isDictionary()) { return null; } PdfIndirectReference indRef = obj.getIndirectReference(); assert indRef != null; Map<PdfIndirectReference, byte[]> serializedCache = indRef.getDocument().serializedObjectsCache; byte[] content = serializedCache.get(indRef); if (content == null) { ByteBuffer bb = new ByteBuffer(); int level = 100; try { serObject(obj, bb, level, serializedCache); } catch (SelfReferenceException e) { return null; } content = bb.toByteArray(); } return new SerializedObjectContent(content); }
private void checkSeparationCS(PdfArray separation) { if (separationColorSpaces.containsKey(separation.getAsName(0))) { boolean altCSIsTheSame; boolean tintTransformIsTheSame; PdfArray sameNameSeparation = separationColorSpaces.get(separation.getAsName(0)); PdfObject cs1 = separation.get(2); PdfObject cs2 = sameNameSeparation.get(2); altCSIsTheSame = isAltCSIsTheSame(cs1, cs2); // TODO(DEVSIX-1672) in fact need to check if objects content is equal. ISO 19005-2, 6.2.4.4 "Separation and DeviceN colour spaces": // In evaluating equivalence, the PDF objects shall be compared, rather than the computational // result of the use of those PDF objects. Compression and whether or not an object is direct or indirect shall be ignored. PdfObject f1Obj = separation.get(3); PdfObject f2Obj = sameNameSeparation.get(3); //Can be a stream or dict boolean bothAllowedType = (f1Obj.getType() == f2Obj.getType()) && (f1Obj.isDictionary() || f1Obj.isStream()); //Check if the indirect references are equal tintTransformIsTheSame = bothAllowedType && f1Obj.equals(f2Obj); if (!altCSIsTheSame || !tintTransformIsTheSame) { throw new PdfAConformanceException(PdfAConformanceException.TINT_TRANSFORM_AND_ALTERNATE_SPACE_SHALL_BE_THE_SAME_FOR_THE_ALL_SEPARATION_CS_WITH_THE_SAME_NAME); } } else { separationColorSpaces.put(separation.getAsName(0), separation); } }
private void checkSeparationCS(PdfArray separation) { if (separationColorSpaces.containsKey(separation.getAsName(0))) { boolean altCSIsTheSame; boolean tintTransformIsTheSame; PdfArray sameNameSeparation = separationColorSpaces.get(separation.getAsName(0)); PdfObject cs1 = separation.get(2); PdfObject cs2 = sameNameSeparation.get(2); altCSIsTheSame = isAltCSIsTheSame(cs1, cs2); // TODO(DEVSIX-1672) in fact need to check if objects content is equal. ISO 19005-2, 6.2.4.4 "Separation and DeviceN colour spaces": // In evaluating equivalence, the PDF objects shall be compared, rather than the computational // result of the use of those PDF objects. Compression and whether or not an object is direct or indirect shall be ignored. PdfObject f1Obj = separation.get(3); PdfObject f2Obj = sameNameSeparation.get(3); //Can be a stream or dict boolean bothAllowedType = (f1Obj.getType() == f2Obj.getType()) && (f1Obj.isDictionary() || f1Obj.isStream()); //Check if the indirect references are equal tintTransformIsTheSame = bothAllowedType && f1Obj.equals(f2Obj); if (!altCSIsTheSame || !tintTransformIsTheSame) { throw new PdfAConformanceException(PdfAConformanceException.TINT_TRANSFORM_AND_ALTERNATE_SPACE_SHALL_BE_THE_SAME_FOR_THE_ALL_SEPARATION_CS_WITH_THE_SAME_NAME); } } else { separationColorSpaces.put(separation.getAsName(0), separation); } }
} else if (normal.isStream()) { PdfDictionary resDict = ((PdfStream) normal).getAsDictionary(PdfName.Resources); if (resDict != null) {
} else if (normal.isStream()) { PdfDictionary resDict = ((PdfStream) normal).getAsDictionary(PdfName.Resources); if (resDict != null) {
if (obj.isStream()) { serDic((PdfDictionary) obj, bb, level - 1, serializedCache); bb.append("$B");
if (!compareDictionariesExtended((PdfDictionary) outDirectObj, (PdfDictionary) cmpDirectObj, currentPath, compareResult)) return false; } else if (cmpDirectObj.isStream()) { if (!compareStreamsExtended((PdfStream) outDirectObj, (PdfStream) cmpDirectObj, currentPath, compareResult)) return false;
PdfObject normal = appDic.get(PdfName.N); PdfFormXObject xObject = null; if (normal.isStream()) { xObject = new PdfFormXObject((PdfStream) normal); } else if (normal.isDictionary()) {
PdfObject normal = appDic.get(PdfName.N); PdfFormXObject xObject = null; if (normal.isStream()) { xObject = new PdfFormXObject((PdfStream) normal); } else if (normal.isDictionary()) {
if (p.isStream()) { PdfStream pStream = (PdfStream) p; if (!isAlreadyChecked(pStream)) {
if (p.isStream()) { PdfStream pStream = (PdfStream) p; if (!isAlreadyChecked(pStream)) {
throw new PdfAConformanceException(PdfAConformanceException.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE); } else { if (n == null || !n.isStream()) throw new PdfAConformanceException(PdfAConformanceException.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE);
throw new PdfAConformanceException(PdfAConformanceException.APPEARANCE_DICTIONARY_OF_WIDGET_SUBTYPE_AND_BTN_FIELD_TYPE_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_DICTIONARY_VALUE); } else { if (n == null || !n.isStream()) throw new PdfAConformanceException(PdfAConformanceException.APPEARANCE_DICTIONARY_SHALL_CONTAIN_ONLY_THE_N_KEY_WITH_STREAM_VALUE);