/** * Constructor. * * @param cat The document catalog that this dictionary is part of. */ public PDDocumentNameDictionary( PDDocumentCatalog cat ) { COSBase names = cat.getCOSObject().getDictionaryObject(COSName.NAMES); if (names != null) { nameDictionary = (COSDictionary)names; } else { nameDictionary = new COSDictionary(); cat.getCOSObject().setItem(COSName.NAMES, nameDictionary); } catalog = cat; }
/** * Set the named destinations that are associated with this document. * * @param dests The destination names. */ public void setDests( PDDestinationNameTreeNode dests ) { nameDictionary.setItem( COSName.DESTS, dests ); //The dests can either be in the document catalog or in the //names dictionary, PDFBox will just maintain the one in the //names dictionary for now unless there is a reason to do //something else. //clear the potentially out of date Dests reference. catalog.getCOSObject().setItem( COSName.DESTS, (COSObjectable)null); }
/** * This method validates if OpenAction entry contains forbidden action type. It checks too if an Additional Action * is present. * * @param ctx * @throws ValidationException * Propagate the ActionManager exception */ protected void validateActions(PreflightContext ctx) throws ValidationException { ContextHelper.validateElement(ctx, catalog.getCOSObject(), ACTIONS_PROCESS); // AA entry if forbidden in PDF/A-1 COSBase aa = catalog.getCOSObject().getItem(DICTIONARY_KEY_ADDITIONAL_ACTION); if (aa != null) { addValidationError(ctx, new ValidationError(ERROR_ACTION_FORBIDDEN_ADDITIONAL_ACTION, "The AA field is forbidden for the Catalog when the PDF is a PDF/A")); } }
/** * Get the destination named tree node. The values in this name tree will be * PDPageDestination objects. * * @return The destination name tree node. */ public PDDestinationNameTreeNode getDests() { PDDestinationNameTreeNode dests = null; COSDictionary dic = (COSDictionary)nameDictionary.getDictionaryObject( COSName.DESTS ); //The document catalog also contains the Dests entry sometimes //so check there as well. if( dic == null ) { dic = (COSDictionary)catalog.getCOSObject().getDictionaryObject( COSName.DESTS ); } if( dic != null ) { dests = new PDDestinationNameTreeNode( dic ); } return dests; }
destCatalog.getCOSObject().setItem(COSName.ACRO_FORM, cloner.cloneForNewDocument(srcAcroForm.getCOSObject()));
COSBase dssElement = catalog.getCOSObject().getDictionaryObject("DSS");
/** * Adds Extensions to the document catalog. So that the use of DSS is identified. Described in * PAdES Part 4, Chapter 4.4. * * @param catalog to add Extensions into */ private void addExtensions(PDDocumentCatalog catalog) { COSDictionary dssExtensions = new COSDictionary(); dssExtensions.setDirect(true); catalog.getCOSObject().setItem("Extensions", dssExtensions); COSDictionary adbeExtension = new COSDictionary(); adbeExtension.setDirect(true); dssExtensions.setItem("ADBE", adbeExtension); adbeExtension.setName("BaseVersion", "1.7"); adbeExtension.setInt("ExtensionLevel", 5); catalog.setVersion("1.7"); }
COSDictionary catalog = docCatalog.getCOSObject(); catalog.setNeedToBeUpdated(true);
COSBase cBase = catalog.getCOSObject().getItem(COSName.getPDFName(DOCUMENT_DICTIONARY_KEY_OUTPUT_INTENTS)); COSArray outputIntents = COSUtils.getAsArray(cBase, document.getDocument());
COSBase base = doc.getDocumentCatalog().getCOSObject().getDictionaryObject(COSName.PERMS); if (base instanceof COSDictionary)
COSArray destThreads = (COSArray) destCatalog.getCOSObject().getDictionaryObject(COSName.THREADS); COSArray srcThreads = (COSArray) cloner.cloneForNewDocument(destCatalog.getCOSObject().getDictionaryObject( COSName.THREADS)); if (destThreads == null) destCatalog.getCOSObject().setItem(COSName.THREADS, srcThreads); destCatalog.getCOSObject().setItem(COSName.NAMES, cloner.cloneForNewDocument(srcNames)); destCatalog.getCOSObject().setItem(COSName.DESTS, cloner.cloneForNewDocument(srcDests)); COSDictionary destLabels = (COSDictionary) destCatalog.getCOSObject().getDictionaryObject( COSName.PAGE_LABELS); COSDictionary srcLabels = (COSDictionary) srcCatalog.getCOSObject() .getDictionaryObject(COSName.PAGE_LABELS); if (srcLabels != null) destNums = new COSArray(); destLabels.setItem(COSName.NUMS, destNums); destCatalog.getCOSObject().setItem(COSName.PAGE_LABELS, destLabels); COSStream destMetadata = (COSStream) destCatalog.getCOSObject().getDictionaryObject(COSName.METADATA); COSStream srcMetadata = (COSStream) srcCatalog.getCOSObject().getDictionaryObject(COSName.METADATA); if (destMetadata == null && srcMetadata != null) mergeInto(srcMetadata, newStream.getCOSObject(), new HashSet<>(Arrays.asList(COSName.FILTER, COSName.LENGTH))); destCatalog.getCOSObject().setItem(COSName.METADATA, newStream);
COSBase cBase = catalog.getCOSObject().getItem(COSName.getPDFName(DOCUMENT_DICTIONARY_KEY_OUTPUT_INTENTS)); COSArray outputIntents = COSUtils.getAsArray(cBase, cosDocument);
if (catalog != null) COSDictionary catalogDict = catalog.getCOSObject(); if (!(catalogDict.getDictionaryObject(COSName.PAGES) instanceof COSDictionary))
catalog.getCOSObject().setNeedToBeUpdated(true);
private List<PDPerms> getPerms() { if(this.catalog != null) { COSDictionary perms = (COSDictionary) this.catalog.getCOSObject().getDictionaryObject(COSName.PERMS); if (perms != null) { List<PDPerms> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new PBoxPDPerms(perms)); return Collections.unmodifiableList(list); } } return Collections.emptyList(); }
private List<CosLang> getLang() { if (this.catalog != null) { COSBase baseLang = catalog.getCOSObject().getDictionaryObject(COSName.LANG); if (baseLang instanceof COSString) { List<CosLang> list = new ArrayList<>(MAX_NUMBER_OF_ELEMENTS); list.add(new PBCosLang((COSString) baseLang)); return Collections.unmodifiableList(list); } } return Collections.emptyList(); }
private PDDocumentCatalogAdditionalActions getAdditionalAction() { if (this.catalog != null) { COSDictionary catalogLocal = this.catalog.getCOSObject(); COSBase aaDictionary = catalogLocal.getDictionaryObject(COSName.AA); if (aaDictionary instanceof COSDictionary) { return new PDDocumentCatalogAdditionalActions((COSDictionary) aaDictionary); } } return null; }
COSDictionary root = document.getDocumentCatalog().getCOSObject(); COSDictionary extensions = (COSDictionary) root.getDictionaryObject(COSName.getPDFName("Extensions")); if (extensions != null) {
COSDictionary catalogDict = doc.getDocumentCatalog().getCOSObject(); COSDictionary permsDict = new COSDictionary(); catalogDict.setItem(COSName.PERMS, permsDict);
@Override public Boolean getcontainsAlternatePresentations() { if (this.catalog != null) { COSDictionary rawCatalog = this.catalog.getCOSObject(); COSDictionary namesDictionary = (COSDictionary) rawCatalog.getDictionaryObject(COSName.NAMES); if (namesDictionary != null) { COSBase alternatePresentations = namesDictionary.getDictionaryObject(COSName.getPDFName(ALTERNATE_PRESENTATIONS)); if (alternatePresentations != null) { return Boolean.TRUE; } } } return Boolean.FALSE; }