/** * Determine if an MCID is available * @return true if the MCID is available, false otherwise */ public boolean hasMcid(){ return properties != null && properties.containsKey(PdfName.MCID); }
/** * Indicates if the catalog has any outlines * * @return {@code true}, if there are outlines and {@code false} otherwise. */ boolean hasOutlines() { return getPdfObject().containsKey(PdfName.Outlines); }
@Override protected void checkFileSpec(PdfDictionary fileSpec) { if (fileSpec.containsKey(PdfName.EF)) { throw new PdfAConformanceException(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_EF_KEY); } }
@Override protected void checkMetaData(PdfDictionary catalog) { if (!catalog.containsKey(PdfName.Metadata)) { throw new PdfAConformanceException(PdfAConformanceException.A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY); } }
@Override protected void checkMetaData(PdfDictionary catalog) { if (!catalog.containsKey(PdfName.Metadata)) { throw new PdfAConformanceException(PdfAConformanceException.A_CATALOG_DICTIONARY_SHALL_CONTAIN_METADATA_ENTRY); } }
@Override protected void checkTrailer(PdfDictionary trailer) { if (trailer.containsKey(PdfName.Encrypt)) { throw new PdfAConformanceException(PdfAConformanceException.KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY); } }
@Override protected void checkFileSpec(PdfDictionary fileSpec) { if (fileSpec.containsKey(PdfName.EF)) { throw new PdfAConformanceException(PdfAConformanceException.FILE_SPECIFICATION_DICTIONARY_SHALL_NOT_CONTAIN_THE_EF_KEY); } }
@Override protected void checkTrailer(PdfDictionary trailer) { if (trailer.containsKey(PdfName.Encrypt)) { throw new PdfAConformanceException(PdfAConformanceException.KEYWORD_ENCRYPT_SHALL_NOT_BE_USED_IN_THE_TRAILER_DICTIONARY); } }
public PdfPolyGeomAnnotation setVertices(PdfArray vertices) { if (getPdfObject().containsKey(PdfName.Path)) { LoggerFactory.getLogger(getClass()).warn(LogMessageConstant.PATH_KEY_IS_PRESENT_VERTICES_WILL_BE_IGNORED); } return (PdfPolyGeomAnnotation) put(PdfName.Vertices, vertices); }
private static String getOrdering(PdfDictionary cidFont) { PdfDictionary cidinfo = cidFont.getAsDictionary(PdfName.CIDSystemInfo); if (cidinfo == null) return null; return cidinfo.containsKey(PdfName.Ordering) ? cidinfo.get(PdfName.Ordering).toString() : null; }
public PdfPolyGeomAnnotation setVertices(float[] vertices) { if (getPdfObject().containsKey(PdfName.Path)) { LoggerFactory.getLogger(getClass()).warn(LogMessageConstant.PATH_KEY_IS_PRESENT_VERTICES_WILL_BE_IGNORED); } return (PdfPolyGeomAnnotation) put(PdfName.Vertices, new PdfArray(vertices)); }
/** * This method returns the NumberTree of Page Labels * * @return returns {@link PdfNumTree} */ public PdfNumTree getPageLabelsTree(boolean createIfNotExists) { if (pageLabels == null && (getPdfObject().containsKey(PdfName.PageLabels) || createIfNotExists)) { pageLabels = new PdfNumTree(this, PdfName.PageLabels); } return pageLabels; }
/** * 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 }
/** * This method merges different fields from two dictionaries into the current one * @param other a dictionary whose fields should be merged into the current dictionary. */ public void mergeDifferent(PdfDictionary other){ for (PdfName key : other.keySet()){ if(!containsKey(key)) put(key, other.get(key)); } }
public PdfLinkAnnotation setDestination(PdfObject destination) { if (getPdfObject().containsKey(PdfName.A)) { getPdfObject().remove(PdfName.A); logger.warn(LogMessageConstant.DESTINATION_NOT_PERMITTED_WHEN_ACTION_IS_SET); } if (destination.isArray() && ((PdfArray)destination).get(0).isNumber()) LoggerFactory.getLogger(PdfLinkAnnotation.class).warn(LogMessageConstant.INVALID_DESTINATION_TYPE); return (PdfLinkAnnotation) put(PdfName.Dest, destination); }
@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); } } }
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); }
@Override protected void checkPageObject(PdfDictionary pageDict, PdfDictionary pageResources) { PdfDictionary actions = pageDict.getAsDictionary(PdfName.AA); if (actions != null) { for (PdfName key : actions.keySet()) { PdfDictionary action = actions.getAsDictionary(key); checkAction(action); } } if (pageDict.containsKey(PdfName.Group) && PdfName.Transparency.equals(pageDict.getAsDictionary(PdfName.Group).getAsName(PdfName.S))) { throw new PdfAConformanceException(PdfAConformanceException.A_GROUP_OBJECT_WITH_AN_S_KEY_WITH_A_VALUE_OF_TRANSPARENCY_SHALL_NOT_BE_INCLUDED_IN_A_PAGE_XOBJECT); } }
private void updateProducerInInfoDictionary() { String producer = null; if (reader == null) { producer = versionInfo.getVersion(); } else { if (info.getPdfObject().containsKey(PdfName.Producer)) { producer = info.getPdfObject().getAsString(PdfName.Producer).toUnicodeString(); } producer = addModifiedPostfix(producer); } info.getPdfObject().put(PdfName.Producer, new PdfString(producer)); }