/** * 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); }
@Override public String getRole() { return currRole.getValue(); }
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; } }
@Override protected PdfObject newInstance() { return new PdfName(); }
@Override protected void checkAction(PdfDictionary action) { if (isAlreadyChecked(action)) return; PdfName s = action.getAsName(PdfName.S); if (getForbiddenActions().contains(s)) { throw new PdfAConformanceException(PdfAConformanceException._0_ACTIONS_ARE_NOT_ALLOWED).setMessageParams(s.getValue()); } if (s.equals(PdfName.Named)) { PdfName n = action.getAsName(PdfName.N); if (n != null && !getAllowedNamedActions().contains(n)) { throw new PdfAConformanceException(PdfAConformanceException.NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED).setMessageParams(n.getValue()); } } if (s.equals(PdfName.SetState) || s.equals(PdfName.NoOp)) { throw new PdfAConformanceException(PdfAConformanceException.DEPRECATED_SETSTATE_AND_NOOP_ACTIONS_ARE_NOT_ALLOWED); } }
private PdfName getSignatureHashKey(String signatureName) throws NoSuchAlgorithmException, IOException { PdfSignature sig = sgnUtil.getSignature(signatureName); PdfString contents = sig.getContents(); byte[] bc = PdfEncodings.convertToBytes(contents.getValue(), null); byte[] bt = null; if (PdfName.ETSI_RFC3161.equals(sig.getSubFilter())) { ASN1InputStream din = new ASN1InputStream(new ByteArrayInputStream(bc)); ASN1Primitive pkcs = din.readObject(); bc = pkcs.getEncoded(); } bt = hashBytesSha1(bc); return new PdfName(convertToHex(bt)); }
private boolean checkDefaultCS(PdfDictionary currentColorSpaces, Boolean fill, PdfName defaultCsName, int numOfComponents) { if (currentColorSpaces == null) return false; if (!currentColorSpaces.containsKey(defaultCsName)) return false; PdfObject defaultCsObj = currentColorSpaces.get(defaultCsName); PdfColorSpace defaultCs = PdfColorSpace.makeColorSpace(defaultCsObj); if (defaultCs instanceof PdfDeviceCs) throw new PdfAConformanceException(PdfAConformanceException.COLOR_SPACE_0_SHALL_BE_DEVICE_INDEPENDENT).setMessageParams(defaultCsName.toString()); if (defaultCs.getNumberOfComponents() != numOfComponents) throw new PdfAConformanceException(PdfAConformanceException.COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS).setMessageParams(defaultCsName.getValue(), numOfComponents); checkColorSpace(defaultCs, currentColorSpaces, false, fill); return true; } }
@Override protected Node toXmlNode(Document document) { Element element = document.createElement("dictKey"); element.appendChild(document.createTextNode(key.toString())); return element; } }
} else { Logger logger = LoggerFactory.getLogger(StructureTreeCopier.class); logger.warn(MessageFormat.format(LogMessageConstant.ROLE_MAPPING_FROM_SOURCE_IS_NOT_COPIED_INVALID, entry.getKey().toString())); continue; copiedMapping = entry.getValue().copyTo(toDocument); PdfName copiedRoleFrom = (PdfName) entry.getKey().copyTo(toDocument); copiedRoleMap.put(copiedRoleFrom, copiedMapping);
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PdfName pdfName = (PdfName) o; return this.compareTo(pdfName) == 0; }
public PdfNamedDestination(String name) { this(new PdfName(name)); }
@Override protected void checkAction(PdfDictionary action) { if (isAlreadyChecked(action)) return; PdfName s = action.getAsName(PdfName.S); if (getForbiddenActions().contains(s)) { throw new PdfAConformanceException(PdfAConformanceException._0_ACTIONS_ARE_NOT_ALLOWED).setMessageParams(s.getValue()); } if (s.equals(PdfName.Named)) { PdfName n = action.getAsName(PdfName.N); if (n != null && !getAllowedNamedActions().contains(n)) { throw new PdfAConformanceException(PdfAConformanceException.NAMED_ACTION_TYPE_0_IS_NOT_ALLOWED).setMessageParams(n.getValue()); } } if (s.equals(PdfName.SetState) || s.equals(PdfName.NoOp)) { throw new PdfAConformanceException(PdfAConformanceException.DEPRECATED_SETSTATE_AND_NOOP_ACTIONS_ARE_NOT_ALLOWED); } }
private PdfName getSignatureHashKey(String signatureName) throws NoSuchAlgorithmException, IOException { PdfSignature sig = sgnUtil.getSignature(signatureName); PdfString contents = sig.getContents(); byte[] bc = PdfEncodings.convertToBytes(contents.getValue(), null); byte[] bt = null; if (PdfName.ETSI_RFC3161.equals(sig.getSubFilter())) { ASN1InputStream din = new ASN1InputStream(new ByteArrayInputStream(bc)); ASN1Primitive pkcs = din.readObject(); bc = pkcs.getEncoded(); } bt = hashBytesSha1(bc); return new PdfName(convertToHex(bt)); }
private boolean checkDefaultCS(PdfDictionary currentColorSpaces, Boolean fill, PdfName defaultCsName, int numOfComponents) { if (currentColorSpaces == null) return false; if (!currentColorSpaces.containsKey(defaultCsName)) return false; PdfObject defaultCsObj = currentColorSpaces.get(defaultCsName); PdfColorSpace defaultCs = PdfColorSpace.makeColorSpace(defaultCsObj); if (defaultCs instanceof PdfDeviceCs) throw new PdfAConformanceException(PdfAConformanceException.COLOR_SPACE_0_SHALL_BE_DEVICE_INDEPENDENT).setMessageParams(defaultCsName.toString()); if (defaultCs.getNumberOfComponents() != numOfComponents) throw new PdfAConformanceException(PdfAConformanceException.COLOR_SPACE_0_SHALL_HAVE_1_COMPONENTS).setMessageParams(defaultCsName.getValue(), numOfComponents); checkColorSpace(defaultCs, currentColorSpaces, false, fill); return true; } }
/** toString method */ public String toString() { return action.toString() + (fields == null ? "" : fields.toString()); } }
public void addDeveloperExtension(PdfDeveloperExtension extension) { PdfDictionary extensions = getPdfObject().getAsDictionary(PdfName.Extensions); if (extensions == null) { extensions = new PdfDictionary(); put(PdfName.Extensions, extensions); } else { PdfDictionary existingExtensionDict = extensions.getAsDictionary(extension.getPrefix()); if (existingExtensionDict != null) { int diff = extension.getBaseVersion().compareTo(existingExtensionDict.getAsName(PdfName.BaseVersion)); if (diff < 0) return; diff = extension.getExtensionLevel() - existingExtensionDict.getAsNumber(PdfName.ExtensionLevel).intValue(); if (diff <= 0) return; } } extensions.put(extension.getPrefix(), extension.getDeveloperExtensions()); }
/** * 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); }
public String getRole() { return currRole.getValue(); }
private static PdfName createDirectName(String name) { return new PdfName(name, true); }
continue; if (key.equals(PdfName.Parent) || key.equals(PdfName.P) || key.equals(PdfName.ModDate)) continue; if (outDict.isStream() && cmpDict.isStream() && (key.equals(PdfName.Filter) || key.equals(PdfName.Length))) continue; if (key.equals(PdfName.BaseFont) || key.equals(PdfName.FontName)) { PdfObject cmpObj = cmpDict.get(key); if (cmpObj != null && cmpObj.isName() && cmpObj.toString().indexOf('+') > 0) { if (!outObj.isName() || outObj.toString().indexOf('+') == -1) { if (compareResult != null && currentPath != null) compareResult.addError(currentPath, MessageFormatUtil.format("PdfDictionary {0} entry: Expected: {1}. Found: {2}", key.toString(), cmpObj.toString(), outObj.toString())); dictsAreSame = false; } else { if (!cmpName.equals(outName)) { if (compareResult != null && currentPath != null) compareResult.addError(currentPath, MessageFormatUtil.format("PdfDictionary {0} entry: Expected: {1}. Found: {2}", key.toString(), cmpObj.toString(), outObj.toString())); dictsAreSame = false; if (key.equals(PdfName.ParentTree) || key.equals(PdfName.PageLabels)) { if (currentPath != null) { currentPath.pushDictItemToPath(key);