com.lowagie.text.pdf
Class PdfDocument

java.lang.Object
  extended bycom.lowagie.text.Document
      extended bycom.lowagie.text.pdf.PdfDocument
All Implemented Interfaces:
DocListener, ElementListener, EventListener

public class PdfDocument
extends Document

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.

Since:
2.0.8 (class was package-private before)
See Also:
Document, DocListener, PdfWriter

Nested Class Summary
static class PdfDocument.Indentation
           
static class PdfDocument.PdfInfo
          PdfInfo is the PDF InfoDictionary.
 
Field Summary
 
Fields inherited from class com.lowagie.text.Document
compress, plainRandomAccess, wmfFontCorrection
 
Constructor Summary
PdfDocument()
          Constructs a new PDF document.
 
Method Summary
 boolean add(Element element)
          Signals that an Element was added to the Document.
 void addWriter(PdfWriter writer)
          Adds a PdfWriter to the PdfDocument.
 void clearTextWrap()
          Method added by Pelikan Stephan
 void close()
          Closes the document.
 float getLeading()
          Getter for the current leading.
 PdfOutline getRootOutline()
          Gets the root outline.
 float getVerticalPosition(boolean ensureNewLine)
          Gets the current vertical page position.
 boolean newPage()
          Makes a new page and sends it to the PdfWriter.
 void open()
          Opens the document.
 void resetFooter()
          Resets the footer of this document.
 void resetHeader()
          Resets the header of this document.
 void resetPageCount()
          Sets the page number to 0.
 void setCollection(PdfCollection collection)
          Sets the collection dictionary.
 void setFooter(HeaderFooter footer)
          Changes the footer of this document.
 void setHeader(HeaderFooter header)
          Changes the header of this document.
 boolean setMarginMirroring(boolean MarginMirroring)
          Set the margin mirroring.
 boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
          Sets the margins.
 void setPageCount(int pageN)
          Sets the page number.
 boolean setPageSize(Rectangle pageSize)
          Sets the pagesize.
 void setXmpMetadata(byte[] xmpMetadata)
          Use this method to set the XMP Metadata.
 
Methods inherited from class com.lowagie.text.Document
addAuthor, addCreationDate, addCreator, addDocListener, addHeader, addKeywords, addProducer, addSubject, addTitle, bottom, bottom, bottomMargin, getHtmlStyleClass, getJavaScript_onLoad, getJavaScript_onUnLoad, getPageNumber, getPageSize, getVersion, isMarginMirroring, isOpen, left, left, leftMargin, removeDocListener, right, right, rightMargin, setHtmlStyleClass, setJavaScript_onLoad, setJavaScript_onUnLoad, top, top, topMargin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfDocument

public PdfDocument()
Constructs a new PDF document.

Method Detail

addWriter

public void addWriter(PdfWriter writer)
               throws DocumentException
Adds a PdfWriter to the PdfDocument.

Parameters:
writer - the PdfWriter that writes everything what is added to this document to an outputstream.
Throws:
DocumentException - on error

getLeading

public float getLeading()
Getter for the current leading.

Returns:
the current leading
Since:
2.1.2

add

public boolean add(Element element)
            throws DocumentException
Signals that an Element was added to the Document.

Specified by:
add in interface ElementListener
Overrides:
add in class Document
Parameters:
element - the element to add
Returns:
true if the element was added, false if not.
Throws:
DocumentException - when a document isn't open yet, or has been closed

open

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.

Specified by:
open in interface DocListener
Overrides:
open in class Document

close

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.

Specified by:
close in interface DocListener
Overrides:
close in class Document

setXmpMetadata

public void setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata.

Parameters:
xmpMetadata - The xmpMetadata to set.

newPage

public boolean newPage()
Makes a new page and sends it to the PdfWriter.

Specified by:
newPage in interface DocListener
Overrides:
newPage in class Document
Returns:
a boolean

setPageSize

public boolean setPageSize(Rectangle pageSize)
Sets the pagesize.

Specified by:
setPageSize in interface DocListener
Overrides:
setPageSize in class Document
Parameters:
pageSize - the new pagesize
Returns:
true if the page size was set

setMargins

public boolean setMargins(float marginLeft,
                          float marginRight,
                          float marginTop,
                          float marginBottom)
Sets the margins.

Specified by:
setMargins in interface DocListener
Overrides:
setMargins in class Document
Parameters:
marginLeft - the margin on the left
marginRight - the margin on the right
marginTop - the margin on the top
marginBottom - the margin on the bottom
Returns:
a boolean

setMarginMirroring

public boolean setMarginMirroring(boolean MarginMirroring)
Description copied from class: Document
Set the margin mirroring. It will mirror margins for odd/even pages.

Note: it will not work with Table.

Specified by:
setMarginMirroring in interface DocListener
Overrides:
setMarginMirroring in class Document
Parameters:
MarginMirroring - true to mirror the margins
Returns:
always true
See Also:
DocListener.setMarginMirroring(boolean)

setPageCount

public void setPageCount(int pageN)
Sets the page number.

Specified by:
setPageCount in interface DocListener
Overrides:
setPageCount in class Document
Parameters:
pageN - the new page number

resetPageCount

public void resetPageCount()
Sets the page number to 0.

Specified by:
resetPageCount in interface DocListener
Overrides:
resetPageCount in class Document

setHeader

public void setHeader(HeaderFooter header)
Changes the header of this document.

Specified by:
setHeader in interface DocListener
Overrides:
setHeader in class Document
Parameters:
header - the new header

resetHeader

public void resetHeader()
Resets the header of this document.

Specified by:
resetHeader in interface DocListener
Overrides:
resetHeader in class Document

setFooter

public void setFooter(HeaderFooter footer)
Changes the footer of this document.

Specified by:
setFooter in interface DocListener
Overrides:
setFooter in class Document
Parameters:
footer - the new footer

resetFooter

public void resetFooter()
Resets the footer of this document.

Specified by:
resetFooter in interface DocListener
Overrides:
resetFooter in class Document

getVerticalPosition

public float getVerticalPosition(boolean ensureNewLine)
Gets the current vertical page position.

Parameters:
ensureNewLine - Tells whether a new line shall be enforced. This may cause side effects for elements that do not terminate the lines they've started because those lines will get terminated.
Returns:
The current vertical page position.

getRootOutline

public PdfOutline getRootOutline()
Gets the root outline. All the outlines must be created with a parent. The first level is created with this outline.

Returns:
the root outline

setCollection

public void setCollection(PdfCollection collection)
Sets the collection dictionary.

Parameters:
collection - a dictionary of type PdfCollection

clearTextWrap

public void clearTextWrap()
Method added by Pelikan Stephan



Copyright © 2011 EGIZ - E-Government Innovation Center. All Rights Reserved.