/** * Adds or replaces the Collection Dictionary in the Catalog. * * @param collection the new collection dictionary. */ void makePackage(PdfCollection collection) { PdfDictionary catalog = reader.getCatalog(); catalog.put(PdfName.COLLECTION, collection); }
/** * Adds or replaces the Collection Dictionary in the Catalog. * * @param collection the new collection dictionary. */ void makePackage(PdfCollection collection) { PdfDictionary catalog = reader.getCatalog(); catalog.put(PdfName.COLLECTION, collection); }
private void loadPagesFromReader(PdfReader reader, List<PdfDictionary> pages, List<RefKey> pagesRef) { PdfObject pagesDict = reader.getCatalog().get(PdfName.PAGES); addPagesFromDict(pagesDict, pages, pagesRef); }
private void loadPagesFromReader(PdfReader reader, List<PdfDictionary> pages, List<RefKey> pagesRef) { PdfObject pagesDict = reader.getCatalog().get(PdfName.PAGES); addPagesFromDict(pagesDict, pages, pagesRef); }
/** * Merges the validation with any validation already in the document or creates * a new one. * @throws IOException */ public void merge() throws IOException { if (used || validated.isEmpty()) return; used = true; PdfDictionary catalog = reader.getCatalog(); PdfObject dss = catalog.get(PdfName.DSS); if (dss == null) createDss(); else updateDss(); }
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 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); }
/** * Sets the option to generate appearances. Not generating appearances * will speed-up form filling but the results can be * unexpected in Acrobat. Don't use it unless your environment is well * controlled. The default is <CODE>true</CODE>. * * @param generateAppearances the option to generate appearances */ public void setGenerateAppearances(boolean generateAppearances) { this.generateAppearances = generateAppearances; PdfDictionary top = reader.getCatalog().getAsDict(PdfName.ACROFORM); if (generateAppearances) top.remove(PdfName.NEEDAPPEARANCES); else top.put(PdfName.NEEDAPPEARANCES, PdfBoolean.PDFTRUE); }
/** * Removes the XFA stream from the document. */ public void removeXfa() { PdfDictionary root = reader.getCatalog(); PdfDictionary acroform = root.getAsDict(PdfName.ACROFORM); acroform.remove(PdfName.XFA); try { xfa = new XfaForm(reader); } catch(Exception e) { throw new ExceptionConverter(e); } }
/** * Return the XFA Object, could be an array, could be a Stream. * Returns null f no XFA Object is present. * @param reader a PdfReader instance * @return the XFA object * @since 2.1.3 */ public static PdfObject getXfaObject(PdfReader reader) { PdfDictionary af = (PdfDictionary)PdfReader.getPdfObjectRelease(reader.getCatalog().get(PdfName.ACROFORM)); if (af == null) { return null; } return PdfReader.getPdfObjectRelease(af.get(PdfName.XFA)); }
/** * Return the XFA Object, could be an array, could be a Stream. * Returns null f no XFA Object is present. * @param reader a PdfReader instance * @return the XFA object * @since 2.1.3 */ public static PdfObject getXfaObject(PdfReader reader) { PdfDictionary af = (PdfDictionary)PdfReader.getPdfObjectRelease(reader.getCatalog().get(PdfName.ACROFORM)); if (af == null) { return null; } return PdfReader.getPdfObjectRelease(af.get(PdfName.XFA)); }
/** * Gets a <CODE>List</CODE> with the bookmarks. It returns <CODE>null</CODE> if * the document doesn't have any bookmarks. * @param reader the document * @return a <CODE>List</CODE> with the bookmarks or <CODE>null</CODE> if the * document doesn't have any */ public static List<HashMap<String, Object>> getBookmark(PdfReader reader) { PdfDictionary catalog = reader.getCatalog(); PdfObject obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.OUTLINES)); if (obj == null || !obj.isDictionary()) return null; PdfDictionary outlines = (PdfDictionary)obj; return SimpleBookmark.getBookmark(reader, outlines, false); }
/** * Gets a <CODE>List</CODE> with the bookmarks. It returns <CODE>null</CODE> if * the document doesn't have any bookmarks. * @param reader the document * @return a <CODE>List</CODE> with the bookmarks or <CODE>null</CODE> if the * document doesn't have any */ public static List<HashMap<String, Object>> getBookmark(PdfReader reader) { PdfDictionary catalog = reader.getCatalog(); PdfObject obj = PdfReader.getPdfObjectRelease(catalog.get(PdfName.OUTLINES)); if (obj == null || !obj.isDictionary()) return null; PdfDictionary outlines = (PdfDictionary)obj; return SimpleBookmark.getBookmark(reader, outlines, false); }
/** * Removes the XFA stream from the document. */ public void removeXfa() { PdfDictionary root = reader.getCatalog(); PdfDictionary acroform = root.getAsDict(PdfName.ACROFORM); acroform.remove(PdfName.XFA); try { xfa = new XfaForm(reader); } catch(Exception e) { throw new ExceptionConverter(e); } }
void deleteOutlines() { PdfDictionary catalog = reader.getCatalog(); PdfObject obj = catalog.get(PdfName.OUTLINES); if (obj == null) return; if (obj instanceof PRIndirectReference) { PRIndirectReference outlines = (PRIndirectReference) obj; outlineTravel(outlines); PdfReader.killIndirect(outlines); } catalog.remove(PdfName.OUTLINES); markUsed(catalog); }
void deleteOutlines() { PdfDictionary catalog = reader.getCatalog(); PdfObject obj = catalog.get(PdfName.OUTLINES); if (obj == null) return; if (obj instanceof PRIndirectReference) { PRIndirectReference outlines = (PRIndirectReference) obj; outlineTravel(outlines); PdfReader.killIndirect(outlines); } catalog.remove(PdfName.OUTLINES); markUsed(catalog); }
static public boolean checkTagged(PdfReader reader) { PdfObject obj = reader.getCatalog().get(PdfName.STRUCTTREEROOT); obj = getDirectObject(obj); if (obj == null || !obj.isDictionary()) return false; PdfDictionary structTreeRoot = (PdfDictionary) obj; obj = PdfStructTreeController.getDirectObject(structTreeRoot.get(PdfName.PARENTTREE)); if (obj == null || !obj.isDictionary()) return false; return true; }
static public boolean checkTagged(PdfReader reader) { PdfObject obj = reader.getCatalog().get(PdfName.STRUCTTREEROOT); obj = getDirectObject(obj); if (obj == null || !obj.isDictionary()) return false; PdfDictionary structTreeRoot = (PdfDictionary) obj; obj = PdfStructTreeController.getDirectObject(structTreeRoot.get(PdfName.PARENTTREE)); if (obj == null || !obj.isDictionary()) return false; return true; }
protected void setJavaScript() throws IOException { HashMap<String, PdfObject> djs = pdf.getDocumentLevelJS(); if (djs.isEmpty()) return; PdfDictionary catalog = reader.getCatalog(); PdfDictionary names = (PdfDictionary) PdfReader.getPdfObject(catalog.get(PdfName.NAMES), catalog); if (names == null) { names = new PdfDictionary(); catalog.put(PdfName.NAMES, names); markUsed(catalog); } markUsed(names); PdfDictionary tree = PdfNameTree.writeTree(djs, this); names.put(PdfName.JAVASCRIPT, addToBody(tree).getIndirectReference()); }
protected void setReader(PdfReader reader) throws BadPdfFormatException { this.reader = reader; PdfObject obj = reader.getCatalog().get(PdfName.STRUCTTREEROOT); obj = getDirectObject(obj); if ((obj == null) || (!obj.isDictionary())) throw new BadPdfFormatException(MessageLocalization.getComposedMessage("no.structtreeroot.found")); structTreeRoot = (PdfDictionary) obj; obj = PdfStructTreeController.getDirectObject(structTreeRoot.get(PdfName.PARENTTREE)); if (obj == null || !obj.isDictionary()) throw new BadPdfFormatException(MessageLocalization.getComposedMessage("the.document.does.not.contain.parenttree")); parentTree = (PdfDictionary) obj; sourceRoleMap = null; sourceClassMap = null; nullReference = null; }