PdfDocumentInfo put(PdfName key, PdfObject value) { getPdfObject().put(key, value); getPdfObject().setModified(); return this; }
public void addRoleMapping(String fromRole, String toRole) { PdfDictionary roleMap = getRoleMap(); PdfObject prevVal = roleMap.put(convertRoleToPdfName(fromRole), convertRoleToPdfName(toRole)); if (prevVal != null && prevVal instanceof PdfName) { Logger logger = LoggerFactory.getLogger(PdfStructTreeRoot.class); logger.warn(MessageFormat.format(LogMessageConstant.MAPPING_IN_STRUCT_ROOT_OVERWRITTEN, fromRole, prevVal, toRole)); } if (roleMap.isIndirect()) { roleMap.setModified(); } else { setModified(); } }
public void setMoreInfo(String key, String value) { PdfName keyName = new PdfName(key); if (value == null) { infoDictionary.remove(keyName); infoDictionary.setModified(); } else { put(keyName, new PdfString(value, PdfEncodings.UNICODE_BIG)); } }
/** * Sets the name of the layer to be displayed in the Layers panel. * @param name the name of the layer. */ public void setName(String name) { getPdfObject().put(PdfName.Name, new PdfString(name, PdfEncodings.UNICODE_BIG)); getPdfObject().setModified(); }
/** * Indicates that the group should be set to that state when the * document is opened in a viewer application. * @param view the view state */ public void setView(boolean view) { PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.ViewState, view ? PdfName.ON : PdfName.OFF); usage.put(PdfName.View, dic); usage.setModified(); }
/** * Sets the visibility expression for content belonging to this * membership dictionary. * @param visibilityExpression A (nested) array of which the first value is /And, /Or, or /Not * followed by a series of indirect references to OCGs or other visibility * expressions. */ public void setVisibilityExpression(PdfVisibilityExpression visibilityExpression) { getPdfObject().put(PdfName.VE, visibilityExpression.getPdfObject()); getPdfObject().setModified(); }
/** * Sets the intents of the layer. * @param intents the list of intents. */ public void setIntents(List<PdfName> intents) { if (intents == null || intents.size() == 0) { getPdfObject().remove(PdfName.Intent); } else if (intents.size() == 1) { getPdfObject().put(PdfName.Intent, intents.get(0)); } else if (intents.size() > 1) { PdfArray array = new PdfArray(); for (PdfName intent : intents) { array.add(intent); } getPdfObject().put(PdfName.Intent, array); } getPdfObject().setModified(); }
/** * Specifies the recommended state for content in this * group when the document (or part of it) is saved by a viewer application to a format * that does not support optional content (for example, an earlier version of * PDF or a raster image format). * @param export the export state */ public void setExport(boolean export) { PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.ExportState, export ? PdfName.ON : PdfName.OFF); usage.put(PdfName.Export, dic); usage.setModified(); }
/** * Indicates that the group contains a pagination artifact. * @param pe one of the following names: "HF" (Header Footer), * "FG" (Foreground), "BG" (Background), or "L" (Logo). */ public void setPageElement(String pe) { PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.Subtype, new PdfName(pe)); usage.put(PdfName.PageElement, dic); usage.setModified(); }
/** * Specifies one or more users for whom this optional content group * is primarily intended. * @param type a name that can be Ind (individual), Ttl (title), or Org (organization). * @param names one or more text strings representing * the name(s) of the individual, position or organization */ public void setUser(String type, String... names) { if (type == null || !type.equals("Ind") && !type.equals("Ttl") && !type.equals("Org")) throw new IllegalArgumentException("Illegal type argument"); if (names == null || names.length == 0) throw new IllegalArgumentException("Illegal names argument"); PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.Type, new PdfName(type)); if (names.length == 1) { dic.put(PdfName.Name, new PdfString(names[0], PdfEncodings.UNICODE_BIG)); } else { PdfArray namesArray = new PdfArray(); for (String name : names) { namesArray.add(new PdfString(name, PdfEncodings.UNICODE_BIG)); } dic.put(PdfName.Name, namesArray); } usage.put(PdfName.User, dic); usage.setModified(); }
/** * Sets the visibility policy for content belonging to this * membership dictionary. Possible values are AllOn, AnyOn, AnyOff and AllOff. * AllOn - Visible only if all of the entries are <B>ON</B>. * AnyOn - Visible if any of the entries are <B>ON</B>. * AnyOff - Visible if any of the entries are <B>OFF</B>. * AllOff - Visible only if all of the entries are <B>OFF</B>. * The default value is AnyOn. * @param visibilityPolicy the visibility policy */ public void setVisibilityPolicy(PdfName visibilityPolicy) { if (visibilityPolicy == null || !PdfName.AllOn.equals(visibilityPolicy) && !PdfName.AnyOn.equals(visibilityPolicy) && !PdfName.AnyOff.equals(visibilityPolicy) && !PdfName.AllOff.equals(visibilityPolicy)) throw new IllegalArgumentException("Argument: visibilityPolicy"); getPdfObject().put(PdfName.P, visibilityPolicy); getPdfObject().setModified(); }
/** * Specifies that the content in this group is intended for * use in printing * @param subtype a name specifying the kind of content controlled by the group; * for example, <B>Trapping</B>, <B>PrintersMarks</B> and <B>Watermark</B> * @param printState indicates that the group should be * set to that state when the document is printed from a viewer application */ public void setPrint(String subtype, boolean printState) { PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.Subtype, new PdfName(subtype)); dic.put(PdfName.PrintState, printState ? PdfName.ON : PdfName.OFF); usage.put(PdfName.Print, dic); usage.setModified(); }
/** * Specifies the language of the content controlled by this * optional content group * @param lang a language string which specifies a language and possibly a locale * (for example, <B>es-MX</B> represents Mexican Spanish) * @param preferred used by viewer applications when there is a partial match but no exact * match between the system language and the language strings in all usage dictionaries */ public void setLanguage(String lang, boolean preferred) { PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.Lang, new PdfString(lang, PdfEncodings.UNICODE_BIG)); if (preferred) dic.put(PdfName.Preferred, PdfName.ON); usage.put(PdfName.Language, dic); usage.setModified(); }
/** * Used by the creating application to store application-specific * data associated with this optional content group. * @param creator a text string specifying the application that created the group * @param subtype a string defining the type of content controlled by the group. Suggested * values include but are not limited to <B>Artwork</B>, for graphic-design or publishing * applications, and <B>Technical</B>, for technical designs such as building plans or * schematics */ public void setCreatorInfo(String creator, String subtype) { PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.Creator, new PdfString(creator, PdfEncodings.UNICODE_BIG)); dic.put(PdfName.Subtype, new PdfName(subtype)); usage.put(PdfName.CreatorInfo, dic); usage.setModified(); }
/** * Specifies a range of magnifications at which the content * in this optional content group is best viewed. * @param min the minimum recommended magnification factors at which the group * should be ON. A negative value will set the default to 0 * @param max the maximum recommended magnification factor at which the group * should be ON. A negative value will set the largest possible magnification supported by the * viewer application */ public void setZoom(float min, float max) { if (min <= 0 && max < 0) return; PdfDictionary usage = getUsage(); PdfDictionary dic = new PdfDictionary(); if (min > 0) dic.put(PdfName.min, new PdfNumber(min)); if (max >= 0) dic.put(PdfName.max, new PdfNumber(max)); usage.put(PdfName.Zoom, dic); usage.setModified(); }
/** * Adds an additional action to the provided {@link PdfObjectWrapper}<{@link PdfDictionary}> wrapper. * * @param wrapper the wrapper to add an additional action to * @param key a {@link PdfName} specifying the name of an additional action * @param action the {@link PdfAction} to add as an additional action */ public static void setAdditionalAction(PdfObjectWrapper<PdfDictionary> wrapper, PdfName key, PdfAction action) { PdfDictionary dic; PdfObject obj = wrapper.getPdfObject().get(PdfName.AA); if (obj != null && obj.isDictionary()) { dic = (PdfDictionary) obj; } else { dic = new PdfDictionary(); } dic.put(key, action.getPdfObject()); wrapper.getPdfObject().put(PdfName.AA, dic); wrapper.getPdfObject().setModified(); }
/** * Removes annotation content item from the tag structure. * If annotation is not added to the document or is not tagged, nothing will happen. * @return {@link TagTreePointer} instance which points at annotation tag parent if annotation was removed, * otherwise returns null. */ public TagTreePointer removeAnnotationTag(PdfAnnotation annotation) { PdfStructElem structElem = null; PdfDictionary annotDic = annotation.getPdfObject(); PdfNumber structParentIndex = (PdfNumber) annotDic.get(PdfName.StructParent); if (structParentIndex != null) { PdfObjRef objRef = document.getStructTreeRoot().findObjRefByStructParentIndex(annotDic.getAsDictionary(PdfName.P), structParentIndex.intValue()); if (objRef != null) { PdfStructElem parent = (PdfStructElem) objRef.getParent(); parent.removeKid(objRef); structElem = parent; } } annotDic.remove(PdfName.StructParent); annotDic.setModified(); if (structElem != null) { return new TagTreePointer(document).setCurrentStructElem(structElem); } return null; }
private void updateDss() throws IOException { PdfDictionary catalog = document.getCatalog().getPdfObject(); catalog.setModified(); PdfDictionary dss = catalog.getAsDictionary(PdfName.DSS); PdfArray ocsps = dss.getAsArray(PdfName.OCSPs);
parent.setModified(); if (kid instanceof PdfDictionary && isStructElem((PdfDictionary) kid)) { if (!parent.isIndirect()) {
private void updateDss() throws IOException { PdfDictionary catalog = document.getCatalog().getPdfObject(); catalog.setModified(); PdfDictionary dss = catalog.getAsDictionary(PdfName.DSS); PdfArray ocsps = dss.getAsArray(PdfName.OCSPs);