/** * An entry specifying the natural language, and optionally locale. Use this * to specify the Language attribute on a Tagged Pdf element. * For the content usage dictionary, use PdfName.Language */ public void setLang(PdfString lang) { put(PdfName.Lang, lang); }
/** * This method sets the root outline element in the catalog. * * @param outline */ void addRootOutline(PdfOutline outline) { if (!outlineMode) return; if (pagesWithOutlines.size() == 0) { put(PdfName.Outlines, outline.getContent()); } }
/** * Sets collection dictionary that a conforming reader shall use to enhance the presentation of file attachments * stored in the PDF document. * * @param collection */ public PdfCatalog setCollection(PdfCollection collection) { put(PdfName.Collection, collection.getPdfObject()); return this; }
/** * This method sets the document viewer preferences, specifying the way the document shall be displayed on the * screen * * @param preferences */ public PdfCatalog setViewerPreferences(PdfViewerPreferences preferences) { return put(PdfName.ViewerPreferences, preferences.getPdfObject()); }
public PdfCatalog setOpenAction(PdfAction action) { return put(PdfName.OpenAction, action.getPdfObject()); }
public PdfCatalog setOpenAction(PdfDestination destination) { return put(PdfName.OpenAction, destination.getPdfObject()); }
private void ensureTreeRootAddedToNames(PdfObject treeRoot, PdfName treeType) { PdfDictionary names = catalog.getPdfObject().getAsDictionary(PdfName.Names); if (names == null) { names = new PdfDictionary(); catalog.put(PdfName.Names, names); names.makeIndirect(this); } names.put(treeType, treeRoot); }
/** * This method sets a page layout of the document * * @param pageLayout */ public PdfCatalog setPageLayout(PdfName pageLayout) { if (pageLayout.equals(PdfName.SinglePage) || pageLayout.equals(PdfName.OneColumn) || pageLayout.equals(PdfName.TwoColumnLeft) || pageLayout.equals(PdfName.TwoColumnRight) || pageLayout.equals(PdfName.TwoPageLeft) || pageLayout.equals(PdfName.TwoPageRight)) { return put(PdfName.PageLayout, pageLayout); } return this; }
/** * This method sets a page mode of the document. * <br> * Valid values are: {@code PdfName.UseNone}, {@code PdfName.UseOutlines}, {@code PdfName.UseThumbs}, * {@code PdfName.FullScreen}, {@code PdfName.UseOC}, {@code PdfName.UseAttachments}. * * @param pageMode page mode. * @return current instance of PdfCatalog */ public PdfCatalog setPageMode(PdfName pageMode) { if (pageMode.equals(PdfName.UseNone) || pageMode.equals(PdfName.UseOutlines) || pageMode.equals(PdfName.UseThumbs) || pageMode.equals(PdfName.FullScreen) || pageMode.equals(PdfName.UseOC) || pageMode.equals(PdfName.UseAttachments)) { return put(PdfName.PageMode, pageMode); } return this; }
/** * Adds {@link PdfOutputIntent} that shall specify the colour characteristics of output devices * on which the document might be rendered. * * @param outputIntent {@link PdfOutputIntent} to add. * @see PdfOutputIntent */ public void addOutputIntent(PdfOutputIntent outputIntent) { checkClosingStatus(); if (outputIntent == null) return; PdfArray outputIntents = catalog.getPdfObject().getAsArray(PdfName.OutputIntents); if (outputIntents == null) { outputIntents = new PdfArray(); catalog.put(PdfName.OutputIntents, outputIntents); } outputIntents.add(outputIntent.getPdfObject()); }
/** * <p> * Adds file associated with PDF document as a whole and identifies the relationship between them. * </p> * <p> * Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. * The method is very similar to {@link PdfDocument#addFileAttachment(String, PdfFileSpec)}. * However, besides adding file description to Names tree, it adds file to array value of the AF key in the document catalog. * </p> * <p> * For associated files their associated file specification dictionaries shall include the AFRelationship key * </p> * * @param description the file description * @param fs file specification dictionary of associated file * @see PdfDocument#addFileAttachment(String, PdfFileSpec) */ public void addAssociatedFile(String description, PdfFileSpec fs) { if (null == ((PdfDictionary) fs.getPdfObject()).get(PdfName.AFRelationship)) { Logger logger = LoggerFactory.getLogger(PdfDocument.class); logger.error(LogMessageConstant.ASSOCIATED_FILE_SPEC_SHALL_INCLUDE_AFRELATIONSHIP); } PdfArray afArray = catalog.getPdfObject().getAsArray(PdfName.AF); if (afArray == null) { afArray = (PdfArray) new PdfArray().makeIndirect(this); catalog.put(PdfName.AF, afArray); } afArray.add(fs.getPdfObject()); addFileAttachment(description, fs); }
public void addDeveloperExtension(PdfDeveloperExtension extension) { PdfDictionary extensions = getPdfObject().getAsDictionary(PdfName.Extensions); if (extensions == null) { extensions = new PdfDictionary(); put(PdfName.Extensions, extensions); } else { PdfDictionary existingExtensionDict = extensions.getAsDictionary(extension.getPrefix()); if (existingExtensionDict != null) { int diff = extension.getBaseVersion().compareTo(existingExtensionDict.getAsName(PdfName.BaseVersion)); if (diff < 0) return; diff = extension.getExtensionLevel() - existingExtensionDict.getAsNumber(PdfName.ExtensionLevel).intValue(); if (diff <= 0) return; } } extensions.put(extension.getPrefix(), extension.getDeveloperExtensions()); }
document.getCatalog().put(PdfName.Perms, docmdp); document.getCatalog().setModified();
document.getCatalog().put(PdfName.Perms, docmdp); document.getCatalog().setModified();
acroForm = new PdfAcroForm(new PdfArray()); acroForm.makeIndirect(document); document.getCatalog().put(PdfName.AcroForm, acroForm.getPdfObject()); document.getCatalog().setModified();
acroForm = new PdfAcroForm(new PdfArray()); acroForm.makeIndirect(document); document.getCatalog().put(PdfName.AcroForm, acroForm.getPdfObject()); document.getCatalog().setModified();
catalog.put(PdfName.DSS, dss);
catalog.put(PdfName.DSS, dss);
catalog.put(PdfName.Version, newPdfVersion.toPdfName()); catalog.setModified(); pdfVersion = newPdfVersion;