/** * Simple method that compares two given PdfBooleans. * * @param outBoolean boolean to compare. * @param cmpBoolean boolean to compare. * @return true if booleans are equal, otherwise false. */ public boolean compareBooleans(PdfBoolean outBoolean, PdfBoolean cmpBoolean) { return cmpBoolean.getValue() == outBoolean.getValue(); }
private boolean compareBooleansExtended(PdfBoolean outBoolean, PdfBoolean cmpBoolean, ObjectPath currentPath, CompareResult compareResult) { if (cmpBoolean.getValue() == outBoolean.getValue()) { return true; } else { if (compareResult != null && currentPath != null) compareResult.addError(currentPath, MessageFormatUtil.format("PdfBoolean. Expected: {0}. Found: {1}.", cmpBoolean.getValue(), outBoolean.getValue())); return false; } }
/** * Returns the value associated to this key as a Boolean. If the value isn't a PdfBoolean, null is returned. * * @param key the key of which the associated value needs to be returned * @return Boolean associated with this key */ public Boolean getAsBool(PdfName key) { PdfBoolean b = getAsBoolean(key); Boolean booleanValue = null; if (b != null) { booleanValue = b.getValue(); } return booleanValue; }
/** * If true, the text specified by the {@link PdfName#Contents} or {@link PdfName#RC} entries * (see {@link PdfAnnotation#getContents()} and {@link PdfMarkupAnnotation#getRichText()}) * is replicated as a caption in the appearance of the line. * @return true, if the annotation text is replicated as a caption, false otherwise. If this property is * not set, default value is used which is <i>false</i>. */ public boolean getContentsAsCaption() { PdfBoolean b = getPdfObject().getAsBoolean(PdfName.Cap); return b != null && b.getValue(); }
@Override protected void checkLogicalStructure(PdfDictionary catalog) { if (checkStructure(conformanceLevel)) { PdfDictionary markInfo = catalog.getAsDictionary(PdfName.MarkInfo); if (markInfo == null || markInfo.getAsBoolean(PdfName.Marked) == null || !markInfo.getAsBoolean(PdfName.Marked).getValue()) { throw new PdfAConformanceException(PdfAConformanceException.A_CATALOG_SHALL_INCLUDE_MARK_INFO_DICTIONARY_WITH_MARKED_TRUE_VALUE); } if (!catalog.containsKey(PdfName.Lang)) { Logger logger = LoggerFactory.getLogger(PdfAChecker.class); logger.warn(PdfAConformanceLogMessageConstant.CATALOG_SHOULD_CONTAIN_LANG_ENTRY); } } }
@Override protected void checkLogicalStructure(PdfDictionary catalog) { if (checkStructure(conformanceLevel)) { PdfDictionary markInfo = catalog.getAsDictionary(PdfName.MarkInfo); if (markInfo == null || markInfo.getAsBoolean(PdfName.Marked) == null || !markInfo.getAsBoolean(PdfName.Marked).getValue()) { throw new PdfAConformanceException(PdfAConformanceException.A_CATALOG_SHALL_INCLUDE_MARK_INFO_DICTIONARY_WITH_MARKED_TRUE_VALUE); } if (!catalog.containsKey(PdfName.Lang)) { Logger logger = LoggerFactory.getLogger(PdfAChecker.class); logger.warn(PdfAConformanceLogMessageConstant.CATALOG_SHOULD_CONTAIN_LANG_ENTRY); } } }
/** * Returns this array as an array of booleans. Will throw a PdfException when it encounters an issue. * * @return this array as an array of booleans * @throws com.itextpdf.kernel.PdfException if one of the values isn't a boolean */ public boolean[] toBooleanArray() { boolean[] rslt = new boolean[size()]; PdfBoolean tmp; for (int k = 0; k < rslt.length; ++ k) { tmp = getAsBoolean(k); if (tmp == null) { throw new PdfException(PdfException.CannotConvertPdfArrayToBooleanArray, this); } rslt[k] = tmp.getValue(); } return rslt; }
@Override protected void checkForm(PdfDictionary form) { if (form != null) { PdfBoolean needAppearances = form.getAsBoolean(PdfName.NeedAppearances); if (needAppearances != null && needAppearances.getValue()) { throw new PdfAConformanceException(PdfAConformanceException.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE); } if (form.containsKey(PdfName.XFA)) { throw new PdfAConformanceException(PdfAConformanceException.THE_INTERACTIVE_FORM_DICTIONARY_SHALL_NOT_CONTAIN_THE_XFA_KEY); } checkResources(form.getAsDictionary(PdfName.DR)); PdfArray fields = form.getAsArray(PdfName.Fields); if (fields != null) { fields = getFormFields(fields); for (PdfObject field : fields) { PdfDictionary fieldDic = (PdfDictionary) field; checkResources(fieldDic.getAsDictionary(PdfName.DR)); } } } }
@Override protected void checkForm(PdfDictionary form) { if (form != null) { PdfBoolean needAppearances = form.getAsBoolean(PdfName.NeedAppearances); if (needAppearances != null && needAppearances.getValue()) { throw new PdfAConformanceException(PdfAConformanceException.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE); } if (form.containsKey(PdfName.XFA)) { throw new PdfAConformanceException(PdfAConformanceException.THE_INTERACTIVE_FORM_DICTIONARY_SHALL_NOT_CONTAIN_THE_XFA_KEY); } checkResources(form.getAsDictionary(PdfName.DR)); PdfArray fields = form.getAsArray(PdfName.Fields); if (fields != null) { fields = getFormFields(fields); for (PdfObject field : fields) { PdfDictionary fieldDic = (PdfDictionary) field; checkResources(fieldDic.getAsDictionary(PdfName.DR)); } } } }
@Override protected void checkForm(PdfDictionary form) { if (form == null) return; PdfBoolean needAppearances = form.getAsBoolean(PdfName.NeedAppearances); if (needAppearances != null && needAppearances.getValue()) { throw new PdfAConformanceException(PdfAConformanceException.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE); } checkResources(form.getAsDictionary(PdfName.DR)); PdfArray fields = form.getAsArray(PdfName.Fields); if (fields != null) { fields = getFormFields(fields); for (PdfObject field : fields) { PdfDictionary fieldDic = (PdfDictionary) field; if (fieldDic.containsKey(PdfName.A) || fieldDic.containsKey(PdfName.AA)) { throw new PdfAConformanceException(PdfAConformanceException.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_OR_AA_ENTRY); } checkResources(fieldDic.getAsDictionary(PdfName.DR)); } } }
@Override protected void checkForm(PdfDictionary form) { if (form == null) return; PdfBoolean needAppearances = form.getAsBoolean(PdfName.NeedAppearances); if (needAppearances != null && needAppearances.getValue()) { throw new PdfAConformanceException(PdfAConformanceException.NEEDAPPEARANCES_FLAG_OF_THE_INTERACTIVE_FORM_DICTIONARY_SHALL_EITHER_NOT_BE_PRESENTED_OR_SHALL_BE_FALSE); } checkResources(form.getAsDictionary(PdfName.DR)); PdfArray fields = form.getAsArray(PdfName.Fields); if (fields != null) { fields = getFormFields(fields); for (PdfObject field : fields) { PdfDictionary fieldDic = (PdfDictionary) field; if (fieldDic.containsKey(PdfName.A) || fieldDic.containsKey(PdfName.AA)) { throw new PdfAConformanceException(PdfAConformanceException.WIDGET_ANNOTATION_DICTIONARY_OR_FIELD_DICTIONARY_SHALL_NOT_INCLUDE_A_OR_AA_ENTRY); } checkResources(fieldDic.getAsDictionary(PdfName.DR)); } } }
if (em != null && !em.getValue()) { cryptoMode |= EncryptionConstants.DO_NOT_ENCRYPT_METADATA; cryptoMode = EncryptionConstants.ENCRYPTION_AES_256; PdfBoolean em5 = encDict.getAsBoolean(PdfName.EncryptMetadata); if (em5 != null && !em5.getValue()) { cryptoMode |= EncryptionConstants.DO_NOT_ENCRYPT_METADATA;
if (em != null && !em.getValue()) { cryptoMode |= EncryptionConstants.DO_NOT_ENCRYPT_METADATA;