/** * Returns an entry from the image dictionary. * @param key a key * @return the value */ public PdfObject get(PdfName key) { return dictionary.get(key); }
protected static PdfDictionary duplicatePdfDictionary(final PdfDictionary original, PdfDictionary copy, final PdfReader newReader) { if (copy == null) copy = new PdfDictionary(original.size()); for (Object element : original.getKeys()) { PdfName key = (PdfName)element; copy.put(key, duplicatePdfObject(original.get(key), newReader)); } return copy; }
/** * Setter for property appendable. * @param appendable New value of property appendable. */ public void setAppendable(final boolean appendable) { this.appendable = appendable; if (appendable) getPdfObject(trailer.get(PdfName.ROOT)); }
private boolean containsInactivePg(PdfDictionary dict, HashSet<RefKey> activeKeys) { PdfObject pg = dict.get(PdfName.PG); if (pg != null && !activeKeys.contains(new RefKey((PdfIndirectReference)pg))) return true; return false; }
/** * Setter for property appendable. * @param appendable New value of property appendable. */ public void setAppendable(final boolean appendable) { this.appendable = appendable; if (appendable) getPdfObject(trailer.get(PdfName.ROOT)); }
/** * Returns the name of the widget annotation (the /NM entry). * @return a String or null (if there's no /NM key) */ public String getWidgetName() { PdfObject name = info.get(PdfName.NM); if (name != null) return name.toString(); return null; }
private void iterateBookmarks(PdfObject outlineRef, final HashMap<Object, PdfObject> names) { while (outlineRef != null) { replaceNamedDestination(outlineRef, names); PdfDictionary outline = (PdfDictionary)getPdfObjectRelease(outlineRef); PdfObject first = outline.get(PdfName.FIRST); if (first != null) { iterateBookmarks(first, names); } outlineRef = outline.get(PdfName.NEXT); } }
private void iterateBookmarks(PdfObject outlineRef, final HashMap<Object, PdfObject> names) { while (outlineRef != null) { replaceNamedDestination(outlineRef, names); PdfDictionary outline = (PdfDictionary)getPdfObjectRelease(outlineRef); PdfObject first = outline.get(PdfName.FIRST); if (first != null) { iterateBookmarks(first, names); } outlineRef = outline.get(PdfName.NEXT); } }
void eliminateFontSubset(final PdfDictionary fonts) { for (Object element : documentFonts.values()) { FontDetails ft = (FontDetails)element; if (fonts.get(ft.getFontName()) != null) ft.setSubset(false); } }
void readPages() throws IOException { if (refsn != null) return; refsp = null; refsn = new ArrayList<PRIndirectReference>(); pageInh = new ArrayList<PdfDictionary>(); iteratePages((PRIndirectReference)reader.catalog.get(PdfName.PAGES)); pageInh = null; reader.rootPages.put(PdfName.COUNT, new PdfNumber(refsn.size())); }
/** * Gets the first entarance of attribute. * @returns PdfObject * @since 5.3.4 */ public PdfObject getAttribute(PdfName name){ PdfDictionary attr = getAsDict(PdfName.A); if (attr != null){ if (attr.contains(name)) return attr.get(name); } return null; }
private void loadPagesFromReader(PdfReader reader, List<PdfDictionary> pages, List<RefKey> pagesRef) { PdfObject pagesDict = reader.getCatalog().get(PdfName.PAGES); addPagesFromDict(pagesDict, pages, pagesRef); }
static boolean existsName(final PdfDictionary dic, final PdfName key, final PdfName value) { PdfObject type = getPdfObjectRelease(dic.get(key)); if (type == null || !type.isName()) return false; PdfName name = (PdfName)type; return name.equals(value); }
protected void setOutlines() throws IOException { if (newBookmarks == null) return; deleteOutlines(); if (newBookmarks.isEmpty()) return; PdfDictionary catalog = reader.getCatalog(); boolean namedAsNames = catalog.get(PdfName.DESTS) != null; writeOutlines(catalog, namedAsNames); markUsed(catalog); }
protected static String getNameString(final PdfDictionary dic, final PdfName key) { PdfObject obj = PdfReader.getPdfObject(dic.get(key)); if (obj == null || !obj.isString()) return null; return ((PdfString)obj).toUnicodeString(); }
protected void checkEmbeddedFile(PdfDictionary embeddedFile) { PdfObject params = getDirectObject(embeddedFile.get(PdfName.PARAMS)); if (params == null) { throw new PdfAConformanceException(embeddedFile, MessageLocalization.getComposedMessage("embedded.file.shall.contain.valid.params.key")); } else if (params.isDictionary()){ PdfObject modDate = ((PdfDictionary)params).get(PdfName.MODDATE); if (modDate == null || !(modDate instanceof PdfString)) { throw new PdfAConformanceException(embeddedFile, MessageLocalization.getComposedMessage("embedded.file.shall.contain.params.key.with.valid.moddate.key")); } } }
protected void setOutlines() throws IOException { if (newBookmarks == null) return; deleteOutlines(); if (newBookmarks.isEmpty()) return; PdfDictionary catalog = reader.getCatalog(); boolean namedAsNames = catalog.get(PdfName.DESTS) != null; writeOutlines(catalog, namedAsNames); markUsed(catalog); }
static String getFontName(final PdfDictionary dic) { if (dic == null) return null; PdfObject type = getPdfObjectRelease(dic.get(PdfName.BASEFONT)); if (type == null || !type.isName()) return null; return PdfName.decodeName(type.toString()); }
void sweepKids(PdfObject obj) { PdfObject oo = PdfReader.killIndirect(obj); if (oo == null || !oo.isDictionary()) return; PdfDictionary dic = (PdfDictionary) oo; PdfArray kids = (PdfArray) PdfReader.killIndirect(dic.get(PdfName.KIDS)); if (kids == null) return; for (int k = 0; k < kids.size(); ++k) { sweepKids(kids.getPdfObject(k)); } }
void sweepKids(PdfObject obj) { PdfObject oo = PdfReader.killIndirect(obj); if (oo == null || !oo.isDictionary()) return; PdfDictionary dic = (PdfDictionary) oo; PdfArray kids = (PdfArray) PdfReader.killIndirect(dic.get(PdfName.KIDS)); if (kids == null) return; for (int k = 0; k < kids.size(); ++k) { sweepKids(kids.getPdfObject(k)); } }