List of usage examples for org.apache.pdfbox.cos COSDictionary getNameAsString
public String getNameAsString(COSName key)
From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFBoxFont.java
License:EUPL
private PDFont findCachedFont(PDFBOXObject pdfObject, FontInfoCache fontInfo) { try {/*w w w . java 2s.c om*/ if (pdfObject.getFontCache().containsKey(fontInfo.fontPath)) { return pdfObject.getFontCache().get(fontInfo.fontPath); } List<COSObject> cosObjects = pdfObject.getDocument().getDocument().getObjectsByType(COSName.FONT); //COSName cosFontName = COSName.getPDFName(fontInfo.fontName); //COSName cosFontFamily = COSName.getPDFName(fontInfo.fontFamily); Iterator<COSObject> cosObjectIt = cosObjects.iterator(); while (cosObjectIt.hasNext()) { COSObject cosObject = cosObjectIt.next(); COSDictionary baseObject = (COSDictionary) cosObject.getObject(); if (baseObject instanceof COSDictionary) { COSDictionary fontDictionary = (COSDictionary) baseObject; COSBase subType = cosObject.getItem(COSName.SUBTYPE); COSDictionary fontDescriptor = (COSDictionary) cosObject.getDictionaryObject(COSName.FONT_DESC); if (fontDescriptor != null) { String fontName = fontDescriptor.getNameAsString(COSName.FONT_NAME); String fontFamily = fontDescriptor.getNameAsString(COSName.FONT_FAMILY); logger.trace("Inspecting Font {} - {}", fontFamily, fontName); if (COSName.TRUE_TYPE.equals(subType)) { if (fontInfo.fontName != null && fontInfo.fontName.equals(fontName) && fontInfo.fontFamily != null && fontInfo.fontFamily.equals(fontFamily)) { // Found it! :) logger.info("Found Font {}", fontInfo.fontName); return new PDTrueTypeFont(fontDictionary); } } else { logger.debug("Font not a TTF"); } } } else { logger.debug("Font not a COSDictionary"); } } } catch (Exception e) { logger.info("Failed to load existing TTF fonts!", e); } return null; }
From source file:modules.PDFFontDependencyExtractorModule.java
License:Apache License
public PDFFontResults extractFontList(File f) throws IOException, InvalidParameterException { PDDocument document;// w w w. ja va 2s .c o m try { document = PDDocument.load(f); } catch (IOException x) { throw new InvalidParameterException("Not a PDF file"); } SortedSet<FontInformation> ret = new TreeSet<FontInformation>(new Comparator<FontInformation>() { @Override public int compare(FontInformation o1, FontInformation o2) { int a = o1.fontName.compareTo(o2.fontName); if (a != 0) return a; else return o1.fontType.compareTo(o2.fontType); } }); document.getDocumentCatalog().getAllPages(); // The code down here is easier as it gets all the fonts used in the // document. Still, this would inlcude unused fonts, so we get the fonts // page by page and add them to a Hash table. for (COSObject c : document.getDocument().getObjectsByType(COSName.FONT)) { if (c == null || !(c.getObject() instanceof COSDictionary)) { continue; // System.out.println(c.getObject()); } COSDictionary fontDictionary = (COSDictionary) c.getObject(); // System.out.println(dic.getNameAsString(COSName.BASE_FONT)); // } // } // int pagen = document.getNumberOfPages(); // i=0; // for (int p=0;p<pagen;p++){ // PDPage page = (PDPage)pages.get(p); // PDResources res = page.findResources(); // //for each page resources // if (res==null) continue; // // get the font dictionary // COSDictionary fonts = (COSDictionary) // res.getCOSDictionary().getDictionaryObject( COSName.FONT ); // for( COSName fontName : fonts.keySet() ) { // COSObject font = (COSObject) fonts.getItem( fontName ); // // if the font has already been visited we ingore it // long objectId = font.getObjectNumber().longValue(); // if (ret.get(objectId)!=null) // continue; // if( font==null || ! (font.getObject() instanceof COSDictionary) ) // continue; // COSDictionary fontDictionary = (COSDictionary)font.getObject(); // Type MUSt be font if (!fontDictionary.getNameAsString(COSName.TYPE).equals("Font")) { continue; } // get the variables FontInformation fi = new FontInformation(); fi.fontType = fontDictionary.getNameAsString(COSName.SUBTYPE); String baseFont = fontDictionary.getNameAsString(COSName.BASE_FONT); if (baseFont == null) { continue; } if (Arrays.binarySearch(standard14, baseFont) >= 0) { continue; } COSDictionary fontDescriptor = (COSDictionary) fontDictionary.getDictionaryObject(COSName.FONT_DESC); COSBase enc = fontDictionary.getItem(COSName.ENCODING); COSBase uni = fontDictionary.getItem(COSName.TO_UNICODE); fontDictionary.getInt(COSName.FIRST_CHAR); fontDictionary.getInt(COSName.LAST_CHAR); String encoding; boolean toUnicode = uni != null; if (enc == null) { encoding = "standard14"; } if (enc instanceof COSString) { encoding = ((COSString) enc).getString(); } else { encoding = "table"; } fi.isSubset = false; boolean t = true; // Type one and TT can have subsets defineing the basename see 5.5.3 // pdfref 1.6 // if (fi.fontType.lastIndexOf(COSName.TYPE1.getName())!=-1 || // fi.fontType.equals(COSName.TRUE_TYPE.getName()) ) if (baseFont != null) { if (baseFont.length() > 6) { for (int k = 0; k < 6; k++) if (!Character.isUpperCase(baseFont.charAt(k))) { t = false; } if (baseFont.charAt(6) != '+') { t = false; } } else { t = false; } fi.isSubset = t; if (fi.isSubset) { fi.baseName = baseFont.substring(0, 6); baseFont = baseFont.substring(7); } } fi.fontFlags = 0; if (fi.fontType.equals(COSName.TYPE0.getName()) || fi.fontType.equals(COSName.TYPE3.getName())) { fi.isEmbedded = true; } if (fontDescriptor != null) { // in Type1 charset indicates font is subsetted if (fontDescriptor.getItem(COSName.CHAR_SET) != null) { fi.isSubset = true; } if (fontDescriptor.getItem(COSName.FONT_FILE) != null || fontDescriptor.getItem(COSName.FONT_FILE3) != null || fontDescriptor.getItem(COSName.FONT_FILE2) != null) { fi.isEmbedded = true; } fi.fontFlags = fontDescriptor.getInt(COSName.getPDFName("Flags")); fi.fontFamily = fontDescriptor.getString(COSName.FONT_FAMILY); fi.fontStretch = fontDescriptor.getString(COSName.FONT_STRETCH); } fi.charset = encoding; fi.fontName = baseFont; fi.isToUnicode = toUnicode; fi.encoding = fontDictionary.getNameAsString(COSName.CID_TO_GID_MAP); ret.add(fi); } // for all fonts HashMultimap<String, FontInformation> m = HashMultimap.create(); for (FontInformation ff : ret) { m.put(ff.fontName, ff); } LinkedList<FontInformation> missing = new LinkedList<FontInformation>(); Set<String> k = m.keySet(); for (String kk : k) { Set<FontInformation> s = m.get(kk); if (s.size() < 1) { continue; } if (s.size() > 1) { boolean found = false; FontInformation ff = null; for (FontInformation fonti : s) { if (!fonti.isEmbedded) { ff = fonti; } else { found = true; } } if (!found) { missing.add(ff); } } else { FontInformation ff = s.iterator().next(); if (!ff.isEmbedded) { missing.add(ff); } } } // } // for all pages // Iterator<FontInformation> it = ret.iterator(); // FontInformation prev = null; // LinkedList<FontInformation> toDelete = new // LinkedList<FontInformation>(); // while (it.hasNext()) { // FontInformation current = it.next(); // // if (prev!= null && prev.fontName.equals(current.fontName) && // (prev.fontType.startsWith("CIDFontType") || // current.fontType.startsWith("CIDFontType"))) // toDelete.add(current); // prev = current; // } // // //ret.removeAll(toDelete); // FontInformation[] retArray =toDelete.toArray(new FontInformation[0]); // if (missing.size() == 0) { missing = null; } else { System.out.println("Found missing fonts: " + f); System.out.println(missing); } return new PDFFontResults(new LinkedList<FontInformation>(ret), missing); }
From source file:net.padaf.preflight.actions.ActionManagerFactory.java
License:Apache License
/** * Create an instance of ActionManager according to the value of the S entry. * If the type entry isn't Action, a ValidationException will be thrown. * /*from ww w .java2 s . com*/ * If the action type isn't authorized in a PDF/A file, an instance of * InvalidAction is returned. * * @param action * the action dictionary used to instantiate the ActionManager * @param cDoc * the COSDocument which contains the action * @param isAA * the Action identifier if it is an additional action * @return * @throws ValidationException */ protected AbstractActionManager createActionManager(COSDictionary action, COSDocument cDoc, String aaKey) throws ValidationException { String type = action.getNameAsString(DICTIONARY_KEY_TYPE); if (type != null && !ACTION_DICTIONARY_VALUE_TYPE.equals(type)) { throw new ValidationException("The given dictionary isn't the dictionary of an Action"); } // ---- S is a mandatory fields. If S entry is missing, the return will // return the InvalidAction manager String s = action.getNameAsString(ACTION_DICTIONARY_KEY_S); // --- Here is authorized actions if (ACTION_DICTIONARY_VALUE_ATYPE_GOTO.equals(s)) { return new GoToAction(this, action, cDoc, aaKey); } if (ACTION_DICTIONARY_VALUE_ATYPE_GOTOR.equals(s)) { return new GoToRemoteAction(this, action, cDoc, aaKey); } if (ACTION_DICTIONARY_VALUE_ATYPE_THREAD.equals(s)) { return new ThreadAction(this, action, cDoc, aaKey); } if (ACTION_DICTIONARY_VALUE_ATYPE_URI.equals(s)) { return new UriAction(this, action, cDoc, aaKey); } if (ACTION_DICTIONARY_VALUE_ATYPE_HIDE.equals(s)) { return new HideAction(this, action, cDoc, aaKey); } if (ACTION_DICTIONARY_VALUE_ATYPE_NAMED.equals(s)) { return new NamedAction(this, action, cDoc, aaKey); } if (ACTION_DICTIONARY_VALUE_ATYPE_SUBMIT.equals(s)) { return new SubmitAction(this, action, cDoc, aaKey); } // --- Here is forbidden actions if (ACTION_DICTIONARY_VALUE_ATYPE_LAUNCH.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_SOUND.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_MOVIE.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_RESET.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_IMPORT.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_JAVASCRIPT.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_SETSTATE.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_NOOP.equals(s)) { return new InvalidAction(this, action, cDoc, aaKey, s); } // ---- The default ActionManager is the undefined one. // Actions defined in a PDF Reference greater than 1.4 will be considered as // Undefined actions, here the list of new actions until the PDF 1.6 : // #GoToE (1.6) : Not PDF/A, uses EmbeddedFiles. // # SetOCGState (1.5) : Not PDF/A, uses optional content. // # Rendition (1.5) : Not PDF/A, use multimedia content. // # Trans (1.5) : ?? // # GoTo3DView (1.6) : ?? return new UndefAction(this, action, cDoc, aaKey, s); }
From source file:net.padaf.preflight.annotation.PDFAbAnnotationFactory.java
License:Apache License
/** * Return an instance of AnnotationValidator if the annotation subtype is * authorized for a PDF/A. Otherwise, returns null and the given list is * updated with the right error code./*from w ww . j ava 2 s . c o m*/ * * If the subtype isn't mentioned in the PDF/A specification and if it doesn't * exist in the PDF Reference 1.4, it will be considered as an invalid * annotation. Here is the list of Annotations which appear after the PDF 1.4 * : * <UL> * <li>Polygon (1.5) * <li>Polyline (1.5) * <li>Caret (1.5) * <li>Screen (1.5) * <li>Watermark (1.6) * <li>3D (1.6) * </UL> * * @param annotDic * @param handler * @param errors * @return */ @Override public AnnotationValidator instantiateAnnotationValidator(COSDictionary annotDic, DocumentHandler handler, List<ValidationError> errors) { AnnotationValidator av = null; String subtype = annotDic.getNameAsString(COSName.getPDFName(DICTIONARY_KEY_SUBTYPE)); if (subtype == null || "".equals(subtype)) { errors.add(new ValidationError(ERROR_ANNOT_MISSING_SUBTYPE)); } else { if (ANNOT_DICTIONARY_VALUE_SUBTYPE_TEXT.equals(subtype)) { av = new TextAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_LINK.equals(subtype)) { av = new LinkAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_FREETEXT.equals(subtype)) { av = new FreeTextAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_LINE.equals(subtype)) { av = new LineAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_SQUARE.equals(subtype) || ANNOT_DICTIONARY_VALUE_SUBTYPE_CIRCLE.equals(subtype)) { av = new SquareCircleAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_HIGHLIGHT.equals(subtype) || ANNOT_DICTIONARY_VALUE_SUBTYPE_UNDERLINE.equals(subtype) || ANNOT_DICTIONARY_VALUE_SUBTYPE_STRIKEOUT.equals(subtype) || ANNOT_DICTIONARY_VALUE_SUBTYPE_SQUILGGLY.equals(subtype)) { av = new MarkupAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_STAMP.equals(subtype)) { av = new RubberStampAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_INK.equals(subtype)) { av = new InkAnnotationValdiator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP.equals(subtype)) { av = new PopupAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_WIDGET.equals(subtype)) { av = new WidgetAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_PRINTERMARK.equals(subtype)) { av = new PrintMarkAnnotationValidator(handler, annotDic); } else if (ANNOT_DICTIONARY_VALUE_SUBTYPE_TRAPNET.equals(subtype)) { av = new TrapNetAnnotationValidator(handler, annotDic); } else { errors.add(new ValidationError(ERROR_ANNOT_FORBIDDEN_SUBTYPE, "The subtype isn't authorized : " + subtype)); } } if (av != null) { // initialize the factory if the Validator has been created av.setFactory(this); } return av; }
From source file:net.padaf.preflight.font.FontValidatorFactory.java
License:Apache License
public FontValidator getFontValidator(COSObject cObj, DocumentHandler handler) throws ValidationException { COSDictionary dic = (COSDictionary) cObj.getObject(); String type = dic.getNameAsString(COSName.getPDFName(DICTIONARY_KEY_TYPE)); String subtype = dic.getNameAsString(COSName.getPDFName(DICTIONARY_KEY_SUBTYPE)); if ((type == null || "".equals(type)) || (subtype == null || "".equals(subtype))) { throw new ValidationException( "Type and/or Subtype keys are missing : " + ERROR_FONTS_DICTIONARY_INVALID); } else {/*from ww w. j a va 2 s . com*/ if (FONT_DICTIONARY_VALUE_TRUETYPE.equals(subtype)) { return new TrueTypeFontValidator(handler, cObj); } else if (FONT_DICTIONARY_VALUE_MMTYPE.equals(subtype) || FONT_DICTIONARY_VALUE_TYPE1.equals(subtype)) { return new Type1FontValidator(handler, cObj); } else if (FONT_DICTIONARY_VALUE_TYPE3.equals(subtype)) { return new Type3FontValidator(handler, cObj); } else if (FONT_DICTIONARY_VALUE_COMPOSITE.equals(subtype)) { return new CompositeFontValidator(handler, cObj); } else if (FONT_DICTIONARY_VALUE_TYPE2.equals(subtype) || FONT_DICTIONARY_VALUE_TYPE1C.equals(subtype) || FONT_DICTIONARY_VALUE_TYPE0C.equals(subtype) || FONT_DICTIONARY_VALUE_TYPE0.equals(subtype)) { // ---- Font managed by a Composite font. // this dictionary will be checked by a CompositeFontValidator return null; } else { throw new ValidationException("Unknown font type : " + subtype); } } }
From source file:net.padaf.preflight.graphics.ExtGStateContainer.java
License:Apache License
/** * Check the TR2 entry. A valid ExtGState hasn't TR2 entry or a TR2 entry * equals to "default"./*from www . ja va 2 s . c om*/ * * @param egs * the graphic state to check * @param error * the list of error to update if the validation fails. * @return true if TR2 entry is missing or equals to "default", false * otherwise. */ protected boolean checkTR2Key(COSDictionary egs, List<ValidationError> error) { if (egs.getItem(COSName.getPDFName("TR2")) != null) { String s = egs.getNameAsString(COSName.getPDFName("TR2")); if (!"default".equals(s)) { error.add(new ValidationError(ValidationConstants.ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY, "TR2 key only expect 'default' value, not '" + s + "'")); return false; } } return true; }
From source file:net.padaf.preflight.graphics.ExtGStateContainer.java
License:Apache License
/** * Check the RI entry of the Graphic State. If the rendering intent entry is * present, the value must be one of the four values defined in the PDF * reference. (@see net.awl.edoc.pdfa.validation.utils.RenderingIntents) * /* w ww.j a va 2s . c o m*/ * @param egs * the graphic state to check * @param error * the list of error to update if the validation fails. * @return true if RI entry is valid, false otherwise. */ protected boolean checkRIKey(COSDictionary egs, List<ValidationError> error) { String rendenringIntent = egs.getNameAsString(COSName.getPDFName("RI")); if (rendenringIntent != null && !"".equals(rendenringIntent) && !RenderingIntents.contains(rendenringIntent)) { error.add(new ValidationError(ValidationConstants.ERROR_GRAPHIC_UNEXPECTED_VALUE_FOR_KEY, "Invalid rendering intent value in Extended graphics state")); return false; } return true; }
From source file:net.padaf.preflight.graphics.XObjFormValidator.java
License:Apache License
/** * A Form XObject may contain a Group object (Key =" Group"). If a Group * object is present, this method checks if the S entry is present and if its * value is different from "Transparency". * //from ww w . j a v a2 s .com * @param error * the list of error to update if the validation fails. * @return true if the validation succeed, false otherwise * @throws ValidationException */ protected boolean checkGroup(List<ValidationError> error) throws ValidationException { COSBase baseGroup = this.xobject.getItem(COSName.getPDFName(XOBJECT_DICTIONARY_KEY_GROUP)); COSDictionary groupDictionary = COSUtils.getAsDictionary(baseGroup, cosDocument); if (groupDictionary != null) { if (!XOBJECT_DICTIONARY_KEY_GROUP.equals(groupDictionary.getNameAsString(DICTIONARY_KEY_TYPE))) { throw new ValidationException("The Group dictionary hasn't Group as Type value"); } String sVal = groupDictionary.getNameAsString(XOBJECT_DICTIONARY_KEY_GROUP_S); if (sVal == null || XOBJECT_DICTIONARY_VALUE_S_TRANSPARENCY.equals(sVal)) { error.add(new ValidationError(ERROR_GRAPHIC_TRANSPARENCY_GROUP, "Group has a transparency S entry or the S entry is null.")); return false; } } return true; }
From source file:net.padaf.preflight.helpers.CatalogValidationHelper.java
License:Apache License
/** * This method checks the content of each OutputIntent. The S entry must * contain GTS_PDFA1. The DestOuputProfile must contain a valid ICC Profile * Stream./* www .jav a 2 s . com*/ * * If there are more than one OutputIntent, they have to use the same ICC * Profile. * * This method returns a list of ValidationError. It is empty if no errors * have been found. * * @param handler * @return * @throws ValidationException */ public List<ValidationError> validateOutputIntent(DocumentHandler handler) throws ValidationException { List<ValidationError> result = new ArrayList<ValidationError>(0); PDDocument pdDocument = handler.getDocument(); PDDocumentCatalog catalog = pdDocument.getDocumentCatalog(); COSDocument cDoc = pdDocument.getDocument(); COSBase cBase = catalog.getCOSDictionary() .getItem(COSName.getPDFName(DOCUMENT_DICTIONARY_KEY_OUTPUT_INTENTS)); COSArray outputIntents = COSUtils.getAsArray(cBase, cDoc); Map<COSObjectKey, Boolean> tmpDestOutputProfile = new HashMap<COSObjectKey, Boolean>(); for (int i = 0; outputIntents != null && i < outputIntents.size(); ++i) { COSDictionary dictionary = COSUtils.getAsDictionary(outputIntents.get(i), cDoc); if (dictionary == null) { result.add(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY, "OutputIntent object is null or isn't a dictionary")); } else { // ---- S entry is mandatory and must be equals to GTS_PDFA1 String sValue = dictionary.getNameAsString(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_S)); if (!OUTPUT_INTENT_DICTIONARY_VALUE_GTS_PDFA1.equals(sValue)) { result.add(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_S_VALUE_INVALID, "The S entry of the OutputIntent isn't GTS_PDFA1")); continue; } // ---- OutputConditionIdentifier is a mandatory field String outputConditionIdentifier = dictionary .getString(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_OUTPUT_CONDITION_IDENTIFIER)); if (outputConditionIdentifier == null || "".equals(outputConditionIdentifier)) { result.add(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY, "The OutputIntentCondition is missing")); continue; } // ---- If OutputConditionIdentifier is "Custom" : // ---- DestOutputProfile and Info are mandatory // ---- DestOutputProfile must be a ICC Profile // ---- Because of PDF/A conforming file needs to specify the color // characteristics, the DestOutputProfile // is checked even if the OutputConditionIdentifier isn't "Custom" COSBase dop = dictionary .getItem(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_DEST_OUTPUT_PROFILE)); ValidationError valer = validateICCProfile(dop, cDoc, tmpDestOutputProfile, handler); if (valer != null) { result.add(valer); continue; } if (OUTPUT_INTENT_DICTIONARY_VALUE_OUTPUT_CONDITION_IDENTIFIER_CUSTOM .equals(outputConditionIdentifier)) { String info = dictionary.getString(COSName.getPDFName(OUTPUT_INTENT_DICTIONARY_KEY_INFO)); if (info == null || "".equals(info)) { result.add(new ValidationError(ERROR_GRAPHIC_OUTPUT_INTENT_INVALID_ENTRY, "The Info entry of a OutputIntent dictionary is missing")); continue; } } } } return result; }
From source file:net.padaf.preflight.helpers.FileSpecificationValidationHelper.java
License:Apache License
@Override public List<ValidationError> innerValidate(DocumentHandler handler) throws ValidationException { List<ValidationError> result = new ArrayList<ValidationError>(0); PDDocument pdfDoc = handler.getDocument(); COSDocument cDoc = pdfDoc.getDocument(); List<?> lCOSObj = cDoc.getObjects(); for (Object o : lCOSObj) { COSObject cObj = (COSObject) o;/*from w ww . ja v a2 s . c o m*/ // ---- If this object represents a Stream // The Dictionary must contain the Length key COSBase cBase = cObj.getObject(); if (cBase instanceof COSDictionary) { COSDictionary dic = (COSDictionary) cBase; String type = dic.getNameAsString(COSName.getPDFName(DICTIONARY_KEY_TYPE)); if (FILE_SPECIFICATION_VALUE_TYPE.equals(type)) { // ---- It is a file specification result.addAll(validateFileSpecification(handler, cObj)); } } } return result; }