Save This Page
Home » iText-src-2.1.3 » com.lowagie » text » pdf » [javadoc | source]
com.lowagie.text.pdf
public class: PdfDocument [javadoc | source]
java.lang.Object
   com.lowagie.text.Document
      com.lowagie.text.pdf.PdfDocument

All Implemented Interfaces:
    DocListener

PdfDocument is the class that is used by PdfWriter to translate a Document into a PDF with different pages.

A PdfDocument always listens to a Document and adds the Pdf representation of every Element that is added to the Document.

Nested Class Summary:
public static class  PdfDocument.PdfInfo  PdfInfo is the PDF InfoDictionary.

A document's trailer may contain a reference to an Info dictionary that provides information about the document. This optional dictionary may contain one or more keys, whose values should be strings.
This object is described in the 'Portable Document Format Reference Manual version 1.3' section 6.10 (page 120-121) 

static class  PdfDocument.PdfCatalog  PdfCatalog is the PDF Catalog-object.

The Catalog is a dictionary that is the root node of the document. It contains a reference to the tree of pages contained in the document, a reference to the tree of objects representing the document's outline, a reference to the document's article threads, and the list of named destinations. In addition, the Catalog indicates whether the document's outline or thumbnail page images should be displayed automatically when the document is viewed and whether some location other than the first page should be shown when the document is opened.
In this class however, only the reference to the tree of pages is implemented.
This object is described in the 'Portable Document Format Reference Manual version 1.3' section 6.2 (page 67-71) 

public static class  PdfDocument.Indentation   
protected static class  PdfDocument.RenderingContext  This is a helper class for adding a Table to a document. 
Field Summary
protected  PdfWriter writer    The PdfWriter
protected  PdfContentByte text    This is the PdfContentByte object, containing the text. 
protected  PdfContentByte graphics    This is the PdfContentByte object, containing the borders and other Graphics. 
protected  float leading    This represents the leading of the lines. 
protected  int alignment    This represents the current alignment of the PDF Elements. 
protected  float currentHeight    This is the current height of the document. 
protected  boolean isSectionTitle    Signals that onParagraph is valid (to avoid that a Chapter/Section title is treated as a Paragraph).
    since: 2.1.2 -
 
protected  int leadingCount    Signals that the current leading has to be subtracted from a YMark object when positive.
    since: 2.1.2 -
 
protected  PdfAction anchorAction    The current active PdfAction when processing an Anchor
protected  int textEmptySize     
protected  byte[] xmpMetadata    XMP Metadata for the page. 
protected  float nextMarginLeft    margin in x direction starting from the left. Will be valid in the next page 
protected  float nextMarginRight    margin in x direction starting from the right. Will be valid in the next page 
protected  float nextMarginTop    margin in y direction starting from the top. Will be valid in the next page 
protected  float nextMarginBottom    margin in y direction starting from the bottom. Will be valid in the next page 
protected  boolean firstPageEvent    Signals that OnOpenDocument should be called. 
protected  PdfLine line    The line that is currently being written. 
protected  ArrayList lines    The lines that are written until now. 
protected  int lastElementType    Holds the type of the last element, that has been added to the document. 
static final  String hangingPunctuation    The characters to be applied the hanging punctuation. 
protected  PdfDocument.Indentation indentation     
protected  PdfDocument.PdfInfo info    some meta information about the Document. 
protected  PdfOutline rootOutline    This is the root outline of the document. 
protected  PdfOutline currentOutline    This is the current PdfOutline in the hierarchy of outlines. 
protected  PdfViewerPreferencesImp viewerPreferences    Contains the Viewer preferences of this PDF document. 
protected  PdfPageLabels pageLabels     
protected  TreeMap localDestinations    Stores the destinations keyed by name. Value is Object[]{PdfAction,PdfIndirectReference,PdfDestintion}
 int jsCounter    Stores a list of document level JavaScript actions. 
protected  HashMap documentLevelJS     
protected static final  DecimalFormat SIXTEEN_DIGITS     
protected  HashMap documentFileAttachment     
protected  String openActionName     
protected  PdfAction openActionAction     
protected  PdfDictionary additionalActions     
protected  PdfCollection collection     
 PdfAnnotationsImp annotationsImp     
protected  int markPoint     
protected  Rectangle nextPageSize    This is the size of the next page. 
protected  HashMap thisBoxSize    This is the size of the several boxes of the current Page. 
protected  HashMap boxSize    This is the size of the several boxes that will be used in the next page. 
protected  boolean pageEmpty    This checks if the page is empty. 
protected  int duration    The duration of the page 
protected  PdfTransition transition    The page transition 
protected  PdfDictionary pageAA     
protected  PdfIndirectReference thumb     
protected  PageResources pageResources    This are the page resources of the current Page. 
protected  boolean strictImageSequence    Holds value of property strictImageSequence. 
protected  float imageEnd    This is the position where the image ends. 
protected  Image imageWait    This is the image that could not be shown on a previous page. 
Fields inherited from com.lowagie.text.Document:
compress,  plainRandomAccess,  wmfFontCorrection,  open,  close,  pageSize,  marginLeft,  marginRight,  marginTop,  marginBottom,  marginMirroring,  javaScript_onLoad,  javaScript_onUnLoad,  htmlStyleClass,  pageN,  header,  footer,  chapternumber
Constructor:
 public PdfDocument() 
Method from com.lowagie.text.pdf.PdfDocument Summary:
add,   add,   addAdditionalAction,   addAnnotation,   addCalculationOrder,   addFileAttachment,   addJavaScript,   addJavaScript,   addOutline,   addPTable,   addSpacing,   addViewerPreference,   addWriter,   analyzeRow,   bottom,   calculateOutlineCount,   carriageReturn,   clearTextWrap,   close,   consumeRowspan,   doFooter,   doHeader,   ensureNewLine,   extractRows,   fitsPage,   flushLines,   getAcroForm,   getBoxSize,   getCatalog,   getDocumentFileAttachment,   getDocumentLevelJS,   getInfo,   getLeading,   getLocalGotoAction,   getMarkPoint,   getPageResources,   getRootOutline,   getVerticalPosition,   incMarkPoint,   indentBottom,   indentLeft,   indentRight,   indentTop,   initPage,   isStrictImageSequence,   localDestination,   localGoto,   mayBeRemoved,   newLine,   newPage,   open,   outlineTree,   remoteGoto,   remoteGoto,   renderCells,   resetFooter,   resetHeader,   resetPageCount,   setAction,   setBoxSize,   setCollection,   setCropBoxSize,   setDuration,   setFooter,   setHeader,   setMarginMirroring,   setMargins,   setNewPageSizeAndMargins,   setOpenAction,   setOpenAction,   setPageAction,   setPageCount,   setPageEmpty,   setPageLabels,   setPageSize,   setSigFlags,   setStrictImageSequence,   setThumbnail,   setTransition,   setViewerPreferences,   setXmpMetadata,   traverseOutlineCount,   writeLineToContent,   writeOutlines
Methods from com.lowagie.text.Document:
add,   addAuthor,   addCreationDate,   addCreator,   addDocListener,   addHeader,   addKeywords,   addProducer,   addSubject,   addTitle,   bottom,   bottom,   bottomMargin,   close,   getHtmlStyleClass,   getJavaScript_onLoad,   getJavaScript_onUnLoad,   getPageNumber,   getPageSize,   getVersion,   isMarginMirroring,   isOpen,   left,   left,   leftMargin,   newPage,   open,   removeDocListener,   resetFooter,   resetHeader,   resetPageCount,   right,   right,   rightMargin,   setFooter,   setHeader,   setHtmlStyleClass,   setJavaScript_onLoad,   setJavaScript_onUnLoad,   setMarginMirroring,   setMargins,   setPageCount,   setPageSize,   top,   top,   topMargin
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.lowagie.text.pdf.PdfDocument Detail:
 public boolean add(Element element) throws DocumentException 
    Signals that an Element was added to the Document.
 protected  void add(Image image) throws PdfException, DocumentException 
    Adds an image to the document.
  void addAdditionalAction(PdfName actionType,
    PdfAction action) 
  void addAnnotation(PdfAnnotation annot) 
  void addCalculationOrder(PdfFormField formField) 
  void addFileAttachment(String description,
    PdfFileSpecification fs) throws IOException 
  void addJavaScript(PdfAction js) 
  void addJavaScript(String name,
    PdfAction js) 
  void addOutline(PdfOutline outline,
    String name) 
    Adds a named outline to the document .
  void addPTable(PdfPTable ptable) throws DocumentException 
    Adds a PdfPTable to the document.
 protected  void addSpacing(float extraspace,
    float oldleading,
    Font f) 
    Adds extra space. This method should probably be rewritten.
  void addViewerPreference(PdfName key,
    PdfObject value) 
 public  void addWriter(PdfWriter writer) throws DocumentException 
    Adds a PdfWriter to the PdfDocument.
 protected  void analyzeRow(ArrayList rows,
    PdfDocument.RenderingContext ctx) 
 float bottom(Table table) 
    Returns the bottomvalue of a Table if it were added to this document.
  void calculateOutlineCount() 
    Updates the count in the outlines.
 protected  void carriageReturn() 
    If the current line is not empty or null, it is added to the arraylist of lines and a new empty line is added.
 public  void clearTextWrap() 
    Method added by Pelikan Stephan
 public  void close() 
    Closes the document. Once all the content has been written in the body, you have to close the body. After that nothing can be written to the body anymore.
 protected  void consumeRowspan(ArrayList row,
    PdfDocument.RenderingContext ctx) 
 protected  void doFooter() throws DocumentException 
 protected  void doHeader() throws DocumentException 
 protected  void ensureNewLine() 
    Ensures that a new line has been started.
 protected ArrayList extractRows(ArrayList cells,
    PdfDocument.RenderingContext ctx) 
 boolean fitsPage(PdfPTable table,
    float margin) 
    Checks if a PdfPTable fits the current page of the PdfDocument.
 protected float flushLines() throws DocumentException 
    Writes all the lines to the text-object.
 PdfAcroForm getAcroForm() 
    Gets the AcroForm object.
 Rectangle getBoxSize(String boxName) 
    Gives the size of a trim, art, crop or bleed box, or null if not defined.
 PdfDocument.PdfCatalog getCatalog(PdfIndirectReference pages) 
    Gets the PdfCatalog-object.
 HashMap getDocumentFileAttachment() 
 HashMap getDocumentLevelJS() 
 PdfDocument.PdfInfo getInfo() 
    Gets the PdfInfo-object.
 public float getLeading() 
    Getter for the current leading.
 PdfAction getLocalGotoAction(String name) 
 int getMarkPoint() 
 PageResources getPageResources() 
 public PdfOutline getRootOutline() 
    Gets the root outline. All the outlines must be created with a parent. The first level is created with this outline.
 public float getVerticalPosition(boolean ensureNewLine) 
    Gets the current vertical page position.
  void incMarkPoint() 
 float indentBottom() 
    Gets the indentation on the bottom side.
 protected float indentLeft() 
    Gets the indentation on the left side.
 protected float indentRight() 
    Gets the indentation on the right side.
 protected float indentTop() 
    Gets the indentation on the top side.
 protected  void initPage() throws DocumentException 
    Initializes a page.

    If the footer/header is set, it is printed.

 boolean isStrictImageSequence() 
    Getter for property strictImageSequence.
 boolean localDestination(String name,
    PdfDestination destination) 
    The local destination to where a local goto with the same name will jump to.
  void localGoto(String name,
    float llx,
    float lly,
    float urx,
    float ury) 
    Implements a link to other part of the document. The jump will be made to a local destination with the same name, that must exist.
 protected boolean mayBeRemoved(ArrayList row) 
 protected  void newLine() throws DocumentException 
    Adds the current line to the list of lines and also adds an empty line.
 public boolean newPage() 
    Makes a new page and sends it to the PdfWriter.
 public  void open() 
    Opens the document.

    You have to open the document before you can begin to add content to the body of the document.

  void outlineTree(PdfOutline outline) throws IOException 
    Recursive method used to write outlines.
  void remoteGoto(String filename,
    String name,
    float llx,
    float lly,
    float urx,
    float ury) 
    Implements a link to another document.
  void remoteGoto(String filename,
    int page,
    float llx,
    float lly,
    float urx,
    float ury) 
    Implements a link to another document.
 protected  void renderCells(PdfDocument.RenderingContext ctx,
    List cells,
    boolean hasToFit) throws DocumentException 
 public  void resetFooter() 
    Resets the footer of this document.
 public  void resetHeader() 
    Resets the header of this document.
 public  void resetPageCount() 
    Sets the page number to 0.
  void setAction(PdfAction action,
    float llx,
    float lly,
    float urx,
    float ury) 
    Implements an action in an area.
  void setBoxSize(String boxName,
    Rectangle size) 
 public  void setCollection(PdfCollection collection) 
    Sets the collection dictionary.
  void setCropBoxSize(Rectangle crop) 
  void setDuration(int seconds) 
    Sets the display duration for the page (for presentations)
 public  void setFooter(HeaderFooter footer) 
    Changes the footer of this document.
 public  void setHeader(HeaderFooter header) 
    Changes the header of this document.
 public boolean setMarginMirroring(boolean MarginMirroring) 
 public boolean setMargins(float marginLeft,
    float marginRight,
    float marginTop,
    float marginBottom) 
    Sets the margins.
 protected  void setNewPageSizeAndMargins() 
  void setOpenAction(String name) 
  void setOpenAction(PdfAction action) 
  void setPageAction(PdfName actionType,
    PdfAction action) 
 public  void setPageCount(int pageN) 
    Sets the page number.
  void setPageEmpty(boolean pageEmpty) 
  void setPageLabels(PdfPageLabels pageLabels) 
    Sets the page labels
 public boolean setPageSize(Rectangle pageSize) 
    Sets the pagesize.
  void setSigFlags(int f) 
  void setStrictImageSequence(boolean strictImageSequence) 
    Setter for property strictImageSequence.
  void setThumbnail(Image image) throws PdfException, DocumentException 
  void setTransition(PdfTransition transition) 
    Sets the transition for the page
  void setViewerPreferences(int preferences) 
 public  void setXmpMetadata(byte[] xmpMetadata) 
    Use this method to set the XMP Metadata.
  void traverseOutlineCount(PdfOutline outline) 
    Recursive method to update the count in the outlines.
  void writeLineToContent(PdfLine line,
    PdfContentByte text,
    PdfContentByte graphics,
    Object[] currentValues,
    float ratio) throws DocumentException 
    Writes a text line to the document. It takes care of all the attributes.

    Before entering the line position must have been established and the text argument must be in text object scope (beginText()).

  void writeOutlines() throws IOException 
    Writes the outline tree to the body of the PDF document.