|
|||||||||
| Home >> All >> com >> lowagie >> [ text overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lowagie.text
Class Document

java.lang.Objectcom.lowagie.text.Document
- All Implemented Interfaces:
- DocListener, ElementListener, java.util.EventListener
- public class Document
- extends java.lang.Object
- implements DocListener
- extends java.lang.Object
A generic Document class.
All kinds of Text-elements can be added to a HTMLDocument.
The Document signals all the listeners when an element has
been added.
Remark:
- Once a document is created you can add some meta information.
- You can also set the headers/footers.
- You have to open the document before you can write content.
- You can only write content (no more meta-formation!) once a document is opened.
- When you change the header/footer on a certain page, this will be effective starting on the next page.
- Ater closing the document, every listener (as well as its
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 define a header and a footer HeaderFooter header = new
HeaderFooter(new Phrase("This is a header."), false); HeaderFooter footer =
new HeaderFooter(new Phrase("This is page "), new Phrase("."));
footer.setAlignment(Element.ALIGN_CENTER);
document.setHeader(header);
document.setFooter(footer); // 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 | |
protected boolean |
close
Has the document already been closed? |
static boolean |
compress
Allows the pdf documents to be produced without compression for debugging purposes. |
protected HeaderFooter |
footer
This is the textual part of the footer |
protected HeaderFooter |
header
This is the textual part of a Page; it can contain a header |
protected java.lang.String |
htmlStyleClass
Style class in HTML body tag |
private static java.lang.String |
ITEXT_VERSION
This constant may only be changed by Paulo Soares and/or Bruno Lowagie. |
protected java.lang.String |
javaScript_onLoad
Content of JavaScript onLoad function |
protected java.lang.String |
javaScript_onUnLoad
Content of JavaScript onUnLoad function |
private java.util.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 |
protected Rectangle |
pageSize
The size of the page. |
protected Watermark |
watermark
The watermark on the pages. |
| Constructor Summary | |
Document()
Constructs a new Document -object. |
|
Document(Rectangle pageSize)
Constructs a new Document -object. |
|
Document(Rectangle pageSize,
float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
Constructs a new Document -object. |
|
| Method Summary | |
boolean |
add(Element element)
Adds an Element to the Document. |
boolean |
add(Watermark watermark)
Sets the Watermark. |
boolean |
addAuthor(java.lang.String author)
Adds the author to a Document. |
boolean |
addCreationDate()
Adds the current date and time to a Document. |
boolean |
addCreator(java.lang.String creator)
Adds the creator to a Document. |
void |
addDocListener(DocListener listener)
Adds a DocListener to the Document. |
boolean |
addHeader(java.lang.String name,
java.lang.String content)
Adds a user defined header to the document. |
boolean |
addKeywords(java.lang.String keywords)
Adds the keywords to a Document. |
boolean |
addProducer()
Adds the producer to a Document. |
boolean |
addSubject(java.lang.String subject)
Adds the subject to a Document. |
boolean |
addTitle(java.lang.String title)
Adds the title to a Document. |
float |
bottom()
Returns the lower left y-coordinate. |
float |
bottom(float margin)
Returns the lower left y-coordinate, considering a given margin. |
float |
bottomMargin()
Returns the bottom margin. |
void |
clearTextWrap()
Clears text wrapping around images (if applicable). |
void |
close()
Closes the document. |
java.lang.String |
getHtmlStyleClass()
Gets the style class of the HTML body tag |
java.lang.String |
getJavaScript_onLoad()
Gets the JavaScript onLoad command. |
java.lang.String |
getJavaScript_onUnLoad()
Gets the JavaScript onUnLoad command. |
int |
getPageNumber()
Returns the current page number. |
Rectangle |
getPageSize()
Gets the pagesize. |
static java.lang.String |
getVersion()
Gets the iText version. |
boolean |
isMarginMirroring()
Gets the margin mirroring flag. |
boolean |
isOpen()
Checks if the document is open. |
float |
left()
Returns the lower left x-coordinate. |
float |
left(float margin)
Returns the lower left x-coordinate considering a given margin. |
float |
leftMargin()
Returns the left margin. |
boolean |
newPage()
Signals that an new page has to be started. |
void |
open()
Opens the document. |
void |
removeDocListener(DocListener listener)
Removes a DocListener from the Document. |
void |
removeWatermark()
Removes the Watermark. |
void |
resetFooter()
Resets the footer of this document. |
void |
resetHeader()
Resets the header of this document. |
void |
resetPageCount()
Sets the page number to 0. |
float |
right()
Returns the upper right x-coordinate. |
float |
right(float margin)
Returns the upper right x-coordinate, considering a given margin. |
float |
rightMargin()
Return the right margin. |
void |
setFooter(HeaderFooter footer)
Changes the footer of this document. |
void |
setHeader(HeaderFooter header)
Changes the header of this document. |
void |
setHtmlStyleClass(java.lang.String htmlStyleClass)
Adds a style class to the HTML body tag |
void |
setJavaScript_onLoad(java.lang.String code)
Adds a JavaScript onLoad function to the HTML body tag |
void |
setJavaScript_onUnLoad(java.lang.String code)
Adds a JavaScript onUnLoad function to the HTML body tag |
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. |
float |
top()
Returns the upper right y-coordinate. |
float |
top(float margin)
Returns the upper right y-coordinate, considering a given margin. |
float |
topMargin()
Returns the top margin. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
ITEXT_VERSION
private static final java.lang.String ITEXT_VERSION
- This constant may only be changed by Paulo Soares and/or Bruno Lowagie.
- See Also:
- Constant Field Values
compress
public static boolean compress
- Allows the pdf documents to be produced without compression for debugging
purposes.
listeners
private java.util.ArrayList listeners
- The DocListener.
open
protected boolean open
- Is the document open or not?
close
protected boolean close
- Has the document already been closed?
pageSize
protected Rectangle pageSize
- The size of the page.
watermark
protected Watermark watermark
- The watermark on the pages.
marginLeft
protected float marginLeft
- margin in x direction starting from the left
marginRight
protected float marginRight
- margin in x direction starting from the right
marginTop
protected float marginTop
- margin in y direction starting from the top
marginBottom
protected float marginBottom
- margin in y direction starting from the bottom
marginMirroring
protected boolean marginMirroring
javaScript_onLoad
protected java.lang.String javaScript_onLoad
- Content of JavaScript onLoad function
javaScript_onUnLoad
protected java.lang.String javaScript_onUnLoad
- Content of JavaScript onUnLoad function
htmlStyleClass
protected java.lang.String htmlStyleClass
- Style class in HTML body tag
pageN
protected int pageN
- Current pagenumber
header
protected HeaderFooter header
- This is the textual part of a Page; it can contain a header
footer
protected HeaderFooter footer
- This is the textual part of the footer
| Constructor Detail |
Document
public Document()
- Constructs a new
Document-object.
Document
public Document(Rectangle pageSize)
- Constructs a new
Document-object.
Document
public Document(Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom)
- Constructs a new
Document-object.
| Method Detail |
addDocListener
public void addDocListener(DocListener listener)
- Adds a
DocListenerto theDocument.
removeDocListener
public void removeDocListener(DocListener listener)
- Removes a
DocListenerfrom theDocument.
add
public boolean add(Element element) throws DocumentException
- Adds an
Elementto theDocument.- Specified by:
addin interfaceElementListener
open
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:
openin interfaceDocListener
setPageSize
public boolean setPageSize(Rectangle pageSize)
- Sets the pagesize.
- Specified by:
setPageSizein interfaceDocListener
add
public boolean add(Watermark watermark)
- Sets the
Watermark.- Specified by:
addin interfaceDocListener
removeWatermark
public void removeWatermark()
- Removes the
Watermark.- Specified by:
removeWatermarkin interfaceDocListener
setMargins
public boolean setMargins(float marginLeft,
float marginRight,
float marginTop,
float marginBottom)
- Sets the margins.
- Specified by:
setMarginsin interfaceDocListener
newPage
public boolean newPage()
throws DocumentException
- Signals that an new page has to be started.
- Specified by:
newPagein interfaceDocListener
setHeader
public void setHeader(HeaderFooter header)
- Changes the header of this document.
- Specified by:
setHeaderin interfaceDocListener
resetHeader
public void resetHeader()
- Resets the header of this document.
- Specified by:
resetHeaderin interfaceDocListener
setFooter
public void setFooter(HeaderFooter footer)
- Changes the footer of this document.
- Specified by:
setFooterin interfaceDocListener
resetFooter
public void resetFooter()
- Resets the footer of this document.
- Specified by:
resetFooterin interfaceDocListener
resetPageCount
public void resetPageCount()
- Sets the page number to 0.
- Specified by:
resetPageCountin interfaceDocListener
setPageCount
public void setPageCount(int pageN)
- Sets the page number.
- Specified by:
setPageCountin interfaceDocListener
getPageNumber
public int getPageNumber()
- Returns the current page number.
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:
closein interfaceDocListener
addHeader
public boolean addHeader(java.lang.String name, java.lang.String content)
- Adds a user defined header to the document.
addTitle
public boolean addTitle(java.lang.String title)
- Adds the title to a Document.
addSubject
public boolean addSubject(java.lang.String subject)
- Adds the subject to a Document.
addKeywords
public boolean addKeywords(java.lang.String keywords)
- Adds the keywords to a Document.
addAuthor
public boolean addAuthor(java.lang.String author)
- Adds the author to a Document.
addCreator
public boolean addCreator(java.lang.String creator)
- Adds the creator to a Document.
addProducer
public boolean addProducer()
- Adds the producer to a Document.
addCreationDate
public boolean addCreationDate()
- Adds the current date and time to a Document.
leftMargin
public float leftMargin()
- Returns the left margin.
rightMargin
public float rightMargin()
- Return the right margin.
topMargin
public float topMargin()
- Returns the top margin.
bottomMargin
public float bottomMargin()
- Returns the bottom margin.
left
public float left()
- Returns the lower left x-coordinate.
right
public float right()
- Returns the upper right x-coordinate.
top
public float top()
- Returns the upper right y-coordinate.
bottom
public float bottom()
- Returns the lower left y-coordinate.
left
public float left(float margin)
- Returns the lower left x-coordinate considering a given margin.
right
public float right(float margin)
- Returns the upper right x-coordinate, considering a given margin.
top
public float top(float margin)
- Returns the upper right y-coordinate, considering a given margin.
bottom
public float bottom(float margin)
- Returns the lower left y-coordinate, considering a given margin.
getPageSize
public Rectangle getPageSize()
- Gets the pagesize.
isOpen
public boolean isOpen()
- Checks if the document is open.
getVersion
public static java.lang.String getVersion()
- Gets the iText version.
setJavaScript_onLoad
public void setJavaScript_onLoad(java.lang.String code)
- Adds a JavaScript onLoad function to the HTML body tag
getJavaScript_onLoad
public java.lang.String getJavaScript_onLoad()
- Gets the JavaScript onLoad command.
setJavaScript_onUnLoad
public void setJavaScript_onUnLoad(java.lang.String code)
- Adds a JavaScript onUnLoad function to the HTML body tag
getJavaScript_onUnLoad
public java.lang.String getJavaScript_onUnLoad()
- Gets the JavaScript onUnLoad command.
setHtmlStyleClass
public void setHtmlStyleClass(java.lang.String htmlStyleClass)
- Adds a style class to the HTML body tag
getHtmlStyleClass
public java.lang.String getHtmlStyleClass()
- Gets the style class of the HTML body tag
clearTextWrap
public void clearTextWrap()
throws DocumentException
- Description copied from interface:
DocListener - Clears text wrapping around images (if applicable).
Method suggested by Pelikan Stephan
- Specified by:
clearTextWrapin interfaceDocListener
setMarginMirroring
public boolean setMarginMirroring(boolean marginMirroring)
- Set the margin mirroring. It will mirror margins for odd/even pages.
Note: it will not work with Table.
- Specified by:
setMarginMirroringin interfaceDocListener
isMarginMirroring
public boolean isMarginMirroring()
- Gets the margin mirroring flag.
|
|||||||||
| Home >> All >> com >> lowagie >> [ text overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lowagie.text.Document