/** * Gets {@code PdfWriter} associated with the document. * * @return PdfWriter associated with the document. */ public PdfWriter getWriter() { checkClosingStatus(); return writer; }
/** * Returns {@code true} if the document is opened in append mode, and {@code false} otherwise. * * @return {@code true} if the document is opened in append mode, and {@code false} otherwise. */ public boolean isAppendMode() { checkClosingStatus(); return properties.appendMode; }
/** * Sets, whether {@link #close()} method shall close associated PdfWriter. * * @param closeWriter true, {@link #close()} method shall close associated PdfWriter, otherwise false. */ public void setCloseWriter(boolean closeWriter) { checkClosingStatus(); this.closeWriter = closeWriter; }
/** * Gets document information dictionary. * * @return document information dictionary. */ public PdfDocumentInfo getDocumentInfo() { checkClosingStatus(); return info; }
/** * Gets {@code PdfReader} associated with the document. * * @return PdfReader associated with the document. */ public PdfReader getReader() { checkClosingStatus(); return reader; }
/** * Sets, whether {@link #close()} method shall close associated PdfReader. * * @param closeReader true, {@link #close()} method shall close associated PdfReader, otherwise false. */ public void setCloseReader(boolean closeReader) { checkClosingStatus(); this.closeReader = closeReader; }
/** * Sets, whether {@link #close()} shall flush unused objects, * e.g. unreachable from PDF Catalog. * * @param flushUnusedObjects false, if {@link #close()} shall not flush unused objects, otherwise true. */ public void setFlushUnusedObjects(boolean flushUnusedObjects) { checkClosingStatus(); this.flushUnusedObjects = flushUnusedObjects; }
/** * Gets PDF catalog. * * @return PDF catalog. */ public PdfCatalog getCatalog() { checkClosingStatus(); return catalog; }
/** * Gets document trailer. * * @return document trailer. */ public PdfDictionary getTrailer() { checkClosingStatus(); return trailer; }
/** * This method initializes an outline tree of the document and sets outline mode to true. */ public void initializeOutlines() { checkClosingStatus(); getOutlines(false); }
/** * Creates next available indirect reference. * * @return created indirect reference. */ public PdfIndirectReference createNextIndirectReference() { checkClosingStatus(); return xref.createNextIndirectReference(this); }
/** * This method returns a complete outline tree of the whole document. * * @param updateOutlines if the flag is true, the method read the whole document and creates outline tree. * If false the method gets cached outline tree (if it was cached via calling getOutlines method before). * @return fully initialize {@link PdfOutline} object. */ public PdfOutline getOutlines(boolean updateOutlines) { checkClosingStatus(); return catalog.getOutlines(updateOutlines); }
/** * Get the first page of the document. * * @return first page of the document. */ public PdfPage getFirstPage() { checkClosingStatus(); return getPage(1); }
/** * Returns files associated with PDF document. * * @return associated files array. */ public PdfArray getAssociatedFiles() { checkClosingStatus(); return catalog.getPdfObject().getAsArray(PdfName.AF); }
/** * Gets number of pages of the document. * * @return number of pages. */ public int getNumberOfPages() { checkClosingStatus(); return catalog.getPageTree().getNumberOfPages(); }
/** * Gets page number by page. * * @param page the page. * @return page number. */ public int getPageNumber(PdfPage page) { checkClosingStatus(); return catalog.getPageTree().getPageNumber(page); }
/** * Adds file attachment at document level. * * @param description the file description * @param fs {@link PdfFileSpec} object. */ public void addFileAttachment(String description, PdfFileSpec fs) { checkClosingStatus(); catalog.addNameToNameTree(description, fs.getPdfObject(), PdfName.EmbeddedFiles); }
/** * Gets the {@link PdfPage} instance by {@link PdfDictionary}. * * @param pageDictionary {@link PdfDictionary} that present page. * @return page by {@link PdfDictionary}. */ public PdfPage getPage(PdfDictionary pageDictionary) { checkClosingStatus(); return catalog.getPageTree().getPage(pageDictionary); }
/** * Gets the page by page number. * * @param pageNum page number. * @return page by page number. may return {@code null} in case the page tree is broken */ public PdfPage getPage(int pageNum) { checkClosingStatus(); return catalog.getPageTree().getPage(pageNum); }
public PdfDocument setTagged() { checkClosingStatus(); if (structTreeRoot == null) { structTreeRoot = new PdfStructTreeRoot(this); catalog.getPdfObject().put(PdfName.StructTreeRoot, structTreeRoot.getPdfObject()); updateValueInMarkInfoDict(PdfName.Marked, PdfBoolean.TRUE); structParentIndex = 0; } return this; }