|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.lowagie.text.DocWriter
com.lowagie.text.html.HtmlWriter
A DocWriter class for HTML.
An HtmlWriter can be added as a DocListener
to a certain Document by getting an instance.
Every Element added to the original Document
will be written to the OutputStream of this HtmlWriter.
Example:
// creation of the document with a certain size and certain margins
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try {
// this will write HTML to the Standard OutputStream
HtmlWriter.getInstance(document, System.out);
// this will write HTML to a file called text.html
HtmlWriter.getInstance(document, new FileOutputStream("text.html"));
// this will write HTML to for instance the OutputStream of a HttpServletResponse-object
HtmlWriter.getInstance(document, response.getOutputStream());
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
// this will close the document and all the OutputStreams listening to it
document.close();
| Field Summary | |
static byte[] |
BEGINCOMMENT
This is a possible HTML-tag. |
static byte[] |
ENDCOMMENT
This is a possible HTML-tag. |
static String |
NBSP
This is a possible HTML-tag. |
| Fields inherited from class com.lowagie.text.DocWriter |
EQUALS, FORWARD, GT, LT, NEWLINE, QUOTE, SPACE, TAB |
| Method Summary | |
boolean |
add(Element element)
Signals that an Element was added to the Document. |
boolean |
add(String string)
Signals that a String was added to the Document. |
void |
close()
Signals that the Document was closed and that no other
Elements will be added. |
static HtmlWriter |
getInstance(Document document,
OutputStream os)
Gets an instance of the HtmlWriter. |
boolean |
isOtherFont(Font font)
Checks if a given font is the same as the font that was last used. |
boolean |
newPage()
Signals that an new page has to be started. |
void |
open()
Signals that the Document has been opened and that
Elements can be added.
|
void |
resetImagepath()
Resets the imagepath. |
void |
setFooter(HeaderFooter footer)
Changes the footer of this document. |
void |
setHeader(HeaderFooter header)
Changes the header of this document. |
void |
setImagepath(String imagepath)
Sets the basepath for images. |
void |
setStandardFont(Font standardfont)
Changes the standardfont. |
| Methods inherited from class com.lowagie.text.DocWriter |
flush, getISOBytes, isCloseStream, isPaused, pause, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setMarginMirroring, setMargins, setPageCount, setPageSize |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final byte[] BEGINCOMMENT
public static final byte[] ENDCOMMENT
public static final String NBSP
| Method Detail |
public static HtmlWriter getInstance(Document document,
OutputStream os)
HtmlWriter.
document - The Document that has to be writtenos - The OutputStream the writer has to write to.
HtmlWriterpublic boolean newPage()
newPage in interface DocListenernewPage in class DocWritertrue if this action succeeded, false if not.
public boolean add(Element element)
throws DocumentException
Element was added to the Document.
add in interface ElementListeneradd in class DocWriterelement - a high level object that has to be translated to HTML
true if the element was added, false if not.
DocumentException - when a document isn't open yet, or has been closedpublic void open()
Document has been opened and that
Elements can be added.
The HEAD-section of the HTML-document is written.
open in interface DocListeneropen in class DocWriterpublic void close()
Document was closed and that no other
Elements will be added.
close in interface DocListenerclose in class DocWriterpublic void setStandardFont(Font standardfont)
standardfont - The fontpublic boolean isOtherFont(Font font)
font - the font of an object
public void setImagepath(String imagepath)
This is especially useful if you add images using a file, rather than an URL. In PDF there is no problem, since the images are added inline, but in HTML it is sometimes necessary to use a relative path or a special path to some images directory.
imagepath - the new imagepathpublic void resetImagepath()
public void setHeader(HeaderFooter header)
setHeader in interface DocListenersetHeader in class DocWriterheader - the new headerpublic void setFooter(HeaderFooter footer)
setFooter in interface DocListenersetFooter in class DocWriterfooter - the new footerpublic boolean add(String string)
String was added to the Document.
string - a String to add to the HTML
true if the string was added, false if not.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||