/** * Initialize opens the document for reading. This is done implicitly * by the constuctor. This should only need to be called directly following * a reset. * @throws IOException */ protected void initialize() throws IOException{ if(document != null){ documentReader = new PdfReader(document); } catalog = documentReader.getCatalog(); }
/** * 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 ); }
/** * Initialize opens the document for reading. This is done implicitly * by the constuctor. This should only need to be called directly following * a reset. * @throws IOException */ protected void initialize() throws IOException{ if(document != null){ documentReader = new PdfReader(document); } catalog = documentReader.getCatalog(); }
/** * Adds or replaces the Collection Dictionary in the Catalog. * @param collection the new collection dictionary. */ void makePackage( PdfCollection collection ) { PdfDictionary catalog = this.reader.getCatalog(); catalog.put( PdfName.COLLECTION, collection ); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfDictionary root = reader.getCatalog(); PdfDictionary names = root.getAsDict(PdfName.NAMES); names.remove(PdfName.EMBEDDEDFILES); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.close(); }
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); }
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); }
void setOutlines() throws IOException { if (this.newBookmarks == null) return; deleteOutlines(); if (this.newBookmarks.isEmpty()) return; PdfDictionary catalog = this.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); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfDictionary root = reader.getCatalog(); PdfDictionary names = root.getAsDict(PdfName.NAMES); PdfDictionary embeddedFiles = names.getAsDict(PdfName.EMBEDDEDFILES); PdfArray namesArray = embeddedFiles.getAsArray(PdfName.NAMES); namesArray.remove(0); namesArray.remove(0); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.close(); }
/** * 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)); }
/** * 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)); }
private Set<PdfDictionary> getEmbeddedFilesDictionaries(PdfReader reader) { Set<PdfDictionary> retSet = new NullSafeSet<PdfDictionary>(); PdfDictionary catalog = reader.getCatalog(); PdfDictionary names = (PdfDictionary) PdfReader.getPdfObject(catalog.get(PdfName.NAMES)); if (names != null) { PdfDictionary embFiles = (PdfDictionary) PdfReader.getPdfObject(names.get(PdfName.EMBEDDEDFILES)); if (embFiles != null) { @SuppressWarnings("unchecked") HashMap<String, PdfObject> embMap = PdfNameTree.readTree(embFiles); for (PdfObject value : embMap.values()) { retSet.add((PdfDictionary) PdfReader.getPdfObject(value)); } } } return retSet; }
void deleteOutlines() { PdfDictionary catalog = reader.getCatalog(); PRIndirectReference outlines = (PRIndirectReference)catalog.get(PdfName.OUTLINES); if (outlines == null) return; outlineTravel(outlines); PdfReader.killIndirect(outlines); catalog.remove(PdfName.OUTLINES); markUsed(catalog); }
void deleteOutlines() { PdfDictionary catalog = this.reader.getCatalog(); PRIndirectReference outlines = (PRIndirectReference)catalog.get(PdfName.OUTLINES); if (outlines == null) return; outlineTravel(outlines); PdfReader.killIndirect(outlines); catalog.remove(PdfName.OUTLINES); markUsed(catalog); }
void deleteOutlines() { PdfDictionary catalog = reader.getCatalog(); PRIndirectReference outlines = (PRIndirectReference)catalog.get(PdfName.OUTLINES); if (outlines == null) return; outlineTravel(outlines); PdfReader.killIndirect(outlines); catalog.remove(PdfName.OUTLINES); markUsed(catalog); }
void setJavaScript() throws IOException { HashMap 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()); }
void setJavaScript() throws IOException { HashMap djs = this.pdf.getDocumentLevelJS(); if (djs.isEmpty()) return; PdfDictionary catalog = this.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()); }