![]() | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
com.lowagie.text.Document
HTMLDocument
.
The Document
signals all the listeners when an element has
been added.
Remark:
OutputStream
) is closed too.
// creation of the document with a certain size and certain margins Document document = new Document(PageSize.A4, 50, 50, 50, 50); try { // creation of the different writers HtmlWriter.getInstance(document , System.out); PdfWriter.getInstance(document , new FileOutputStream("text.pdf")); // we add some meta information to the document document.addAuthor("Bruno Lowagie"); document.addSubject("This is the result of a Test."); // we open the document for writing document.open(); document.add(new Paragraph("Hello world")); } catch(DocumentException de) { System.err.println(de.getMessage()); } document.close();
Field Summary | |
private static String |
|
protected int |
|
protected boolean |
|
static boolean |
|
protected HeaderFooter |
|
protected HeaderFooter |
|
protected String |
|
protected String |
|
protected String |
|
private ArrayList |
|
protected float |
|
protected float |
|
protected boolean | |
protected float |
|
protected float |
|
protected boolean |
|
protected int |
|
protected Rectangle |
|
Constructor Summary | |
| |
Method Summary | |
boolean | |
boolean |
|
boolean |
|
boolean |
|
void |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
float |
|
float |
|
float |
|
void |
|
String |
|
String |
|
String |
|
int |
|
Rectangle |
|
static String |
|
boolean |
|
boolean |
|
float |
|
float |
|
float |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
float |
|
float |
|
float |
|
void |
|
void |
|
void |
|
void |
|
void |
|
boolean |
|
boolean |
|
void |
|
boolean |
|
float |
|
float |
|
float |
|
private static final String ITEXT_VERSION
This constant may only be changed by Paulo Soares and/or Bruno Lowagie.
protected int chapternumber
This is a chapter number in case ChapterAutoNumber is used.
protected boolean close
Has the document already been closed?
public static boolean compress
Allows the pdf documents to be produced without compression for debugging purposes.
protected String htmlStyleClass
Style class in HTML body tag
protected String javaScript_onLoad
Content of JavaScript onLoad function
protected String javaScript_onUnLoad
Content of JavaScript onUnLoad function
private ArrayList listeners
The DocListener.
protected float marginBottom
margin in y direction starting from the bottom
protected float marginLeft
margin in x direction starting from the left
protected boolean marginMirroring
protected float marginRight
margin in x direction starting from the right
protected float marginTop
margin in y direction starting from the top
protected boolean open
Is the document open or not?
protected int pageN
Current pagenumber
public Document()
Constructs a newDocument
-object.
public Document(Rectangle pageSize)
Constructs a newDocument
-object.
- Parameters:
pageSize
- the pageSize
public Document(Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom)
Constructs a newDocument
-object.
- Parameters:
pageSize
- the pageSizemarginLeft
- the margin on the leftmarginRight
- the margin on the rightmarginTop
- the margin on the topmarginBottom
- the margin on the bottom
public boolean add(Element element) throws DocumentException
Adds anElement
to theDocument
.
- Specified by:
- add in interface ElementListener
- Parameters:
element
- theElement
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
public boolean addAuthor(String author)
Adds the author to a Document.
- Parameters:
author
- the name of the author
- Returns:
true
if successful,false
otherwise
public boolean addCreationDate()
Adds the current date and time to a Document.
- Returns:
true
if successful,false
otherwise
public boolean addCreator(String creator)
Adds the creator to a Document.
- Parameters:
creator
- the name of the creator
- Returns:
true
if successful,false
otherwise
public void addDocListener(DocListener listener)
Adds aDocListener
to theDocument
.
- Parameters:
listener
- the new DocListener.
public boolean addHeader(String name, String content)
Adds a user defined header to the document.
- Parameters:
name
- the name of the headercontent
- the content of the header
- Returns:
true
if successful,false
otherwise
public boolean addKeywords(String keywords)
Adds the keywords to a Document.
- Parameters:
keywords
- adds the keywords to the document
- Returns:
true
if successful,false
otherwise
public boolean addProducer()
Adds the producer to a Document.
- Returns:
true
if successful,false
otherwise
public boolean addSubject(String subject)
Adds the subject to a Document.
- Parameters:
subject
- the subject
- Returns:
true
if successful,false
otherwise
public boolean addTitle(String title)
Adds the title to a Document.
- Parameters:
title
- the title
- Returns:
true
if successful,false
otherwise
public float bottom()
Returns the lower left y-coordinate.
- Returns:
- the lower left y-coordinate
public float bottom(float margin)
Returns the lower left y-coordinate, considering a given margin.
- Parameters:
margin
- a margin
- Returns:
- the lower left y-coordinate
public float bottomMargin()
Returns the bottom margin.
- Returns:
- the bottom margin
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
public String getHtmlStyleClass()
Gets the style class of the HTML body tag
- Returns:
- the style class of the HTML body tag
public String getJavaScript_onLoad()
Gets the JavaScript onLoad command.
- Returns:
- the JavaScript onLoad command
public String getJavaScript_onUnLoad()
Gets the JavaScript onUnLoad command.
- Returns:
- the JavaScript onUnLoad command
public int getPageNumber()
Returns the current page number.
- Returns:
- the current page number
public static final String getVersion()
Gets the iText version. This method may only be changed by Paulo Soares and/or Bruno Lowagie.
- Returns:
- iText version
public boolean isMarginMirroring()
Gets the margin mirroring flag.
- Returns:
- the margin mirroring flag
public boolean isOpen()
Checks if the document is open.
- Returns:
true
if the document is open
public float left()
Returns the lower left x-coordinate.
- Returns:
- the lower left x-coordinate
public float left(float margin)
Returns the lower left x-coordinate considering a given margin.
- Parameters:
margin
- a margin
- Returns:
- the lower left x-coordinate
public float leftMargin()
Returns the left margin.
- Returns:
- the left margin
public boolean newPage()
Signals that an new page has to be started.
- Specified by:
- newPage in interface DocListener
- Returns:
true
if the page was added,false
if not.
public void open()
Opens the document. Once the document is opened, you can't write any Header- or Meta-information anymore. 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
public void removeDocListener(DocListener listener)
Removes aDocListener
from theDocument
.
- Parameters:
listener
- the DocListener that has to be removed.
public void resetFooter()
Resets the footer of this document.
- Specified by:
- resetFooter in interface DocListener
public void resetHeader()
Resets the header of this document.
- Specified by:
- resetHeader in interface DocListener
public void resetPageCount()
Sets the page number to 0.
- Specified by:
- resetPageCount in interface DocListener
public float right()
Returns the upper right x-coordinate.
- Returns:
- the upper right x-coordinate
public float right(float margin)
Returns the upper right x-coordinate, considering a given margin.
- Parameters:
margin
- a margin
- Returns:
- the upper right x-coordinate
public float rightMargin()
Return the right margin.
- Returns:
- the right margin
public void setFooter(HeaderFooter footer)
Changes the footer of this document.
- Specified by:
- setFooter in interface DocListener
- Parameters:
footer
- the new footer
public void setHeader(HeaderFooter header)
Changes the header of this document.
- Specified by:
- setHeader in interface DocListener
- Parameters:
header
- the new header
public void setHtmlStyleClass(String htmlStyleClass)
Adds a style class to the HTML body tag
- Parameters:
htmlStyleClass
- the style class for the HTML body tag
public void setJavaScript_onLoad(String code)
Adds a JavaScript onLoad function to the HTML body tag
- Parameters:
code
- the JavaScript code to be executed on load of the HTML page
public void setJavaScript_onUnLoad(String code)
Adds a JavaScript onUnLoad function to the HTML body tag
- Parameters:
code
- the JavaScript code to be executed on unload of the HTML page
public boolean setMarginMirroring(boolean marginMirroring)
Set the margin mirroring. It will mirror margins for odd/even pages. Note: it will not work withTable
.
- Specified by:
- setMarginMirroring in interface DocListener
- Parameters:
marginMirroring
-true
to mirror the margins
- Returns:
- always
true
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Sets the margins.
- Specified by:
- setMargins in interface DocListener
- Parameters:
marginLeft
- the margin on the leftmarginRight
- the margin on the rightmarginTop
- the margin on the topmarginBottom
- the margin on the bottom
- Returns:
- a
boolean
public void setPageCount(int pageN)
Sets the page number.
- Specified by:
- setPageCount in interface DocListener
- Parameters:
pageN
- the new page number
public boolean setPageSize(Rectangle pageSize)
Sets the pagesize.
- Specified by:
- setPageSize in interface DocListener
- Parameters:
pageSize
- the new pagesize
- Returns:
- a
boolean
public float top()
Returns the upper right y-coordinate.
- Returns:
- the upper right y-coordinate
public float top(float margin)
Returns the upper right y-coordinate, considering a given margin.
- Parameters:
margin
- a margin
- Returns:
- the upper right y-coordinate
public float topMargin()
Returns the top margin.
- Returns:
- the top margin