/** * Checks if this node is a dictionary item with a specific key. * * @param key the key of the node we're looking for * @return true if this node is a dictionary item with a specific key */ public boolean isDictionaryNode(PdfName key) { return (key != null) && key.equals(this.key); }
/** * Simple method that compares two given PdfNames. * * @param outName name to compare. * @param cmpName name to compare. * @return true if names are equal, otherwise false. */ public boolean compareNames(PdfName outName, PdfName cmpName) { return cmpName.equals(outName); }
/** * Gets the visibility policy for content belonging to this * optional content membership dictionary. */ public PdfName getVisibilityPolicy() { PdfName visibilityPolicy = getPdfObject().getAsName(PdfName.P); if (visibilityPolicy == null || !visibilityPolicy.equals(PdfName.AllOn) && !visibilityPolicy.equals(PdfName.AllOff) && !visibilityPolicy.equals(PdfName.AnyOn) && !visibilityPolicy.equals(PdfName.AnyOff)) return PdfName.AnyOn; return visibilityPolicy; }
@Override public boolean equals(Object obj) { return obj.getClass() == getClass() && key.equals(((DictPathItem) obj).key); }
private static boolean imageColorSpaceIsKnown(PdfDictionary imageDictionary, PdfDictionary colorSpaceDic) { PdfName cs = imageDictionary.getAsName(PdfName.ColorSpace); if (cs == null || cs.equals(PdfName.DeviceGray) || cs.equals(PdfName.DeviceRGB) || cs.equals(PdfName.DeviceCMYK)) return true; return colorSpaceDic != null && colorSpaceDic.containsKey(cs); }
/** * 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"); } }
/** * Creates a visibility expression. * @param operator should be either PdfName#And, PdfName#Or, or PdfName#Not */ public PdfVisibilityExpression(PdfName operator) { super(new PdfArray()); if (operator == null || !PdfName.Or.equals(operator) && !PdfName.And.equals(operator) && !PdfName.Not.equals(operator)) throw new IllegalArgumentException("Invalid operator"); getPdfObject().add(operator); }
/** * Creates a new PdfLayerMembership instance by its PdfDictionary, which must be an indirect object. * * @param membershipDictionary the membership dictionary, must have an indirect reference. */ public PdfLayerMembership(PdfDictionary membershipDictionary) { super(membershipDictionary); ensureObjectIsAddedToDocument(membershipDictionary); if (!PdfName.OCMD.equals(membershipDictionary.getAsName(PdfName.Type))) throw new IllegalArgumentException("Invalid membershipDictionary."); }
/** * Method to to distinguish struct elements from other elements of the logical tree (like mcr or struct tree root). */ public static boolean isStructElem(PdfDictionary dictionary) { return (PdfName.StructElem.equals(dictionary.getAsName(PdfName.Type)) || dictionary.containsKey(PdfName.S)); // required key of the struct elem }
private List<PdfLinkAnnotation> getLinkAnnotations(int pageNum, PdfDocument document) { List<PdfLinkAnnotation> linkAnnotations = new ArrayList<>(); List<PdfAnnotation> annotations = document.getPage(pageNum).getAnnotations(); for (PdfAnnotation annotation : annotations) { if (PdfName.Link.equals(annotation.getSubtype())) { linkAnnotations.add((PdfLinkAnnotation) annotation); } } return linkAnnotations; }
private Signature initSignature(PublicKey key) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { String digestAlgorithm = getDigestAlgorithm(); if (PdfName.Adbe_x509_rsa_sha1.equals(getFilterSubtype())) digestAlgorithm = "SHA1withRSA"; Signature signature = SignUtils.getSignatureHelper(digestAlgorithm, provider); signature.initVerify(key); return signature; }
private void addRow(PdfName key, PdfObject value) { dictionary.put(key, value); int index = -1; for (PdfName name : dictionary.keySet()) { ++index; if (name.equals(key)) { break; } } keys.add(index, key); fireTableRowsInserted(index, index); }
private Signature initSignature(PublicKey key) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { String digestAlgorithm = getDigestAlgorithm(); if (PdfName.Adbe_x509_rsa_sha1.equals(getFilterSubtype())) digestAlgorithm = "SHA1withRSA"; Signature signature = SignUtils.getSignatureHelper(digestAlgorithm, provider); signature.initVerify(key); return signature; }
private boolean isNotMetadataPdfStream(PdfStream pdfStream) { return pdfStream.getAsName(PdfName.Type) == null || (pdfStream.getAsName(PdfName.Type) != null && !pdfStream.getAsName(PdfName.Type).equals(PdfName.Metadata)); }
private PdfDictionary getPdfAOutputIntent(PdfArray outputIntents) { for (int i = 0; i < outputIntents.size(); ++i) { PdfName outputIntentSubtype = outputIntents.getAsDictionary(i).getAsName(PdfName.S); if (PdfName.GTS_PDFA1.equals(outputIntentSubtype)) { return outputIntents.getAsDictionary(i); } } return null; }
public PdfImageXObject getImage(PdfName name) { PdfStream image = getResource(PdfName.XObject).getAsStream(name); return image != null && PdfName.Image.equals(image.getAsName(PdfName.Subtype)) ? new PdfImageXObject(image) : null; }
private boolean compareNamesExtended(PdfName outName, PdfName cmpName, ObjectPath currentPath, CompareResult compareResult) { if (cmpName.equals(outName)) { return true; } else { if (compareResult != null && currentPath != null) compareResult.addError(currentPath, MessageFormatUtil.format("PdfName. Expected: {0}. Found: {1}", cmpName.toString(), outName.toString())); return false; } }
private PdfDictionary getPdfAOutputIntent(PdfArray outputIntents) { for (int i = 0; i < outputIntents.size(); ++i) { PdfName outputIntentSubtype = outputIntents.getAsDictionary(i).getAsName(PdfName.S); if (PdfName.GTS_PDFA1.equals(outputIntentSubtype)) { return outputIntents.getAsDictionary(i); } } return null; }
public static PdfEncryptedPayload wrap(PdfDictionary dictionary) { PdfName type = dictionary.getAsName(PdfName.Type); if (type != null && !type.equals(PdfName.EncryptedPayload)) { throw new PdfException(PdfException.EncryptedPayloadShallHaveTypeEqualsToEncryptedPayloadIfPresent); } if (dictionary.getAsName(PdfName.Subtype) == null) { throw new PdfException(PdfException.EncryptedPayloadShallHaveSubtype); } return new PdfEncryptedPayload(dictionary); }