public PdfName getName() { return ((PdfArray)getPdfObject()).getAsName(1); }
/** * Constructs a new PdfVisibilityExpression instance by its raw PdfArray. * @param visibilityExpressionArray the array representing the visibility expression */ public PdfVisibilityExpression(PdfArray visibilityExpressionArray) { super(visibilityExpressionArray); PdfName operator = visibilityExpressionArray.getAsName(0); if (visibilityExpressionArray.size() < 1 || !PdfName.Or.equals(operator) && !PdfName.And.equals(operator) && !PdfName.Not.equals(operator)) { throw new IllegalArgumentException("Invalid visibilityExpressionArray"); } }
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); } }
@Override public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSpaces) { PdfObject filter = inlineImage.get(PdfName.Filter); if (filter instanceof PdfName) { if (filter.equals(PdfName.LZWDecode)) { throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); } } else if (filter instanceof PdfArray) { for (int i = 0; i < ((PdfArray) filter).size(); i++) { PdfName f = ((PdfArray) filter).getAsName(i); if (f.equals(PdfName.LZWDecode)) { throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); } } } checkImage(inlineImage, currentColorSpaces); }
@Override public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSpaces) { PdfObject filter = inlineImage.get(PdfName.Filter); if (filter instanceof PdfName) { if (filter.equals(PdfName.LZWDecode)) { throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); } } else if (filter instanceof PdfArray) { for (int i = 0; i < ((PdfArray) filter).size(); i++) { PdfName f = ((PdfArray) filter).getAsName(i); if (f.equals(PdfName.LZWDecode)) { throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); } } } checkImage(inlineImage, currentColorSpaces); }
@Override public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSpaces) { PdfObject filter = inlineImage.get(PdfName.Filter); if (filter instanceof PdfName) { if (filter.equals(PdfName.LZWDecode)) throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); if (filter.equals(PdfName.Crypt)) { throw new PdfAConformanceException(PdfAConformanceException.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE); } } else if (filter instanceof PdfArray) { for (int i = 0; i < ((PdfArray) filter).size(); i++) { PdfName f = ((PdfArray) filter).getAsName(i); if (f.equals(PdfName.LZWDecode)) throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); if (f.equals(PdfName.Crypt)) { throw new PdfAConformanceException(PdfAConformanceException.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE); } } } checkImage(inlineImage, currentColorSpaces); }
@Override public void checkInlineImage(PdfStream inlineImage, PdfDictionary currentColorSpaces) { PdfObject filter = inlineImage.get(PdfName.Filter); if (filter instanceof PdfName) { if (filter.equals(PdfName.LZWDecode)) throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); if (filter.equals(PdfName.Crypt)) { throw new PdfAConformanceException(PdfAConformanceException.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE); } } else if (filter instanceof PdfArray) { for (int i = 0; i < ((PdfArray) filter).size(); i++) { PdfName f = ((PdfArray) filter).getAsName(i); if (f.equals(PdfName.LZWDecode)) throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED); if (f.equals(PdfName.Crypt)) { throw new PdfAConformanceException(PdfAConformanceException.CRYPT_FILTER_IS_NOT_PERMITTED_INLINE_IMAGE); } } } checkImage(inlineImage, currentColorSpaces); }
/** * PDF 2.0. Sets an array of names of Viewer preference settings that * shall be enforced by PDF processors and that shall not be overridden by * subsequent selections in the application user interface * * @param enforce array of names specifying settings to enforce in the PDF processors * @return this {@link PdfViewerPreferences} instance */ public PdfViewerPreferences setEnforce(PdfArray enforce) { for (int i = 0; i < enforce.size(); i++) { PdfName curEnforce = enforce.getAsName(i); if (curEnforce == null) { throw new IllegalArgumentException("Enforce array shall contain PdfName entries"); } else if (PdfName.PrintScaling.equals(curEnforce)) { // This name may appear in the Enforce array only if the corresponding entry in // the viewer preferences dictionary specifies a valid value other than AppDefault PdfName curPrintScaling = getPdfObject().getAsName(PdfName.PrintScaling); if (curPrintScaling == null || PdfName.AppDefault.equals(curPrintScaling)) { throw new PdfException(PdfException.PrintScalingEnforceEntryInvalid); } } } return put(PdfName.Enforce, enforce); }
mappedRole = mappingArr.getAsName(0); mappedNsDict = mappingArr.getAsDictionary(1);
/** * @param colorSpaceName the name of the color space. If null, a bi-tonal (black and white) color space is assumed. * @return the components per pixel for the specified color space */ private static int getComponentsPerPixel(PdfName colorSpaceName, PdfDictionary colorSpaceDic) { if (colorSpaceName == null) return 1; if (colorSpaceName.equals(PdfName.DeviceGray)) return 1; if (colorSpaceName.equals(PdfName.DeviceRGB)) return 3; if (colorSpaceName.equals(PdfName.DeviceCMYK)) return 4; if (colorSpaceDic != null) { PdfArray colorSpace = colorSpaceDic.getAsArray(colorSpaceName); if (colorSpace != null) { if (PdfName.Indexed.equals(colorSpace.getAsName(0))) { return 1; } } else { PdfName tempName = colorSpaceDic.getAsName(colorSpaceName); if (tempName != null) { return getComponentsPerPixel(tempName, colorSpaceDic); } } } throw new InlineImageParseException(PdfException.UnexpectedColorSpace1).setMessageParams(colorSpaceName); }
PdfName f = ((PdfArray) filter).getAsName(i); if (f.equals(PdfName.LZWDecode)) throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED);
PdfName f = ((PdfArray) filter).getAsName(i); if (f.equals(PdfName.LZWDecode)) throw new PdfAConformanceException(PdfAConformanceException.LZWDECODE_FILTER_IS_NOT_PERMITTED);
PdfName csType = array.getAsName(0); if (PdfName.CalGray.equals(csType)) return new CalGray((PdfCieBasedCs.CalGray) pdfColorSpace, getColorants(operands)[0]);
} else if (filterObject instanceof PdfArray) { filtersArray = (PdfArray) filterObject; filterName = filtersArray.getAsName(0); } else { throw new PdfException(PdfException.FilterIsNotANameOrArray);
else if (pdfObject.isArray()) { PdfArray array = (PdfArray) pdfObject; PdfName csType = array.getAsName(0); if (PdfName.CalGray.equals(csType)) return new PdfCieBasedCs.CalGray(array);