| java.lang.Object com.lowagie.text.DocWriter com.lowagie.text.html.HtmlWriter
HtmlWriter | public class HtmlWriter extends DocWriter (Code) | | 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();
|
Method Summary | |
public boolean | add(Element element) Signals that an Element was added to the Document . | public boolean | add(String string) Signals that a String was added to the Document . | public void | close() Signals that the Document was closed and that no other
Elements will be added. | public static HtmlWriter | getInstance(Document document, OutputStream os) Gets an instance of the HtmlWriter .
Parameters: document - The Document that has to be written Parameters: os - The OutputStream the writer has to write to. | protected void | initFooter() | protected void | initHeader() | public boolean | isOtherFont(Font font) Checks if a given font is the same as the font that was last used. | public boolean | newPage() Signals that an new page has to be started. | public void | open() Signals that the Document has been opened and that
Elements can be added. | public void | resetImagepath() Resets the imagepath. | public void | setFooter(HeaderFooter footer) Changes the footer of this document. | public void | setHeader(HeaderFooter header) Changes the header of this document. | public void | setImagepath(String imagepath) Sets the basepath for images.
This is especially useful if you add images using a file,
rather than an URL. | public void | setStandardFont(Font standardfont) Changes the standardfont. | protected void | write(Element element, int indent) Writes the HTML representation of an element. | protected void | write(Font font, Properties styleAttributes) Writes the representation of a Font . | protected void | writeComment(String comment) Writes some comment. | protected void | writeCssProperty(String prop, String value) Writes out a CSS property. | protected void | writeHeader(Meta meta) Writes a Metatag in the header. | protected void | writeJavaScript(Header header) Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header. | protected void | writeLink(Header header) Writes a link in the header. | protected void | writeSection(Section section, int indent) Writes the HTML representation of a section. |
BEGINCOMMENT | final public static byte[] BEGINCOMMENT(Code) | | This is a possible HTML-tag.
|
ENDCOMMENT | final public static byte[] ENDCOMMENT(Code) | | This is a possible HTML-tag.
|
NBSP | final public static String NBSP(Code) | | This is a possible HTML-tag.
|
currentfont | protected Stack currentfont(Code) | | This is the current font of the HTML.
|
imagepath | protected String imagepath(Code) | | This is a path for images.
|
markup | protected Properties markup(Code) | | Store the markup properties of a MarkedObject.
|
pageN | protected int pageN(Code) | | Stores the page number.
|
standardfont | protected Font standardfont(Code) | | This is the standard font of the HTML.
|
HtmlWriter | protected HtmlWriter(Document doc, OutputStream os)(Code) | | Constructs a HtmlWriter .
Parameters: doc - The Document that has to be written as HTML Parameters: os - The OutputStream the writer has to write to. |
add | public boolean add(Element element) throws DocumentException(Code) | | Signals that an Element was added to the Document .
Parameters: element - a high level object that has to be translated to HTML true if the element was added, false if not. throws: DocumentException - when a document isn't open yet, or has been closed |
add | public boolean add(String string)(Code) | | Signals that a String was added to the Document .
Parameters: string - a String to add to the HTML true if the string was added, false if not. throws: DocumentException - when a document isn't open yet, or has been closed |
close | public void close()(Code) | | Signals that the Document was closed and that no other
Elements will be added.
|
getInstance | public static HtmlWriter getInstance(Document document, OutputStream os)(Code) | | Gets an instance of the HtmlWriter .
Parameters: document - The Document that has to be written Parameters: os - The OutputStream the writer has to write to. a new HtmlWriter |
initFooter | protected void initFooter()(Code) | | Adds the header to the top of the Document
|
initHeader | protected void initHeader()(Code) | | Adds the header to the top of the Document
|
isOtherFont | public boolean isOtherFont(Font font)(Code) | | Checks if a given font is the same as the font that was last used.
Parameters: font - the font of an object true if the font differs |
newPage | public boolean newPage()(Code) | | Signals that an new page has to be started.
true if this action succeeded, false if not. throws: DocumentException - when a document isn't open yet, or has been closed |
open | public void open()(Code) | | Signals that the Document has been opened and that
Elements can be added.
The HEAD -section of the HTML-document is written.
|
resetImagepath | public void resetImagepath()(Code) | | Resets the imagepath.
|
setFooter | public void setFooter(HeaderFooter footer)(Code) | | Changes the footer of this document.
Parameters: footer - the new footer |
setHeader | public void setHeader(HeaderFooter header)(Code) | | Changes the header of this document.
Parameters: header - the new header |
setImagepath | public void setImagepath(String imagepath)(Code) | | Sets the basepath for images.
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.
Parameters: imagepath - the new imagepath |
setStandardFont | public void setStandardFont(Font standardfont)(Code) | | Changes the standardfont.
Parameters: standardfont - The font |
write | protected void write(Element element, int indent) throws IOException(Code) | | Writes the HTML representation of an element.
Parameters: element - the element Parameters: indent - the indentation throws: IOException - |
write | protected void write(Font font, Properties styleAttributes) throws IOException(Code) | | Writes the representation of a Font .
Parameters: font - a Font Parameters: styleAttributes - the style of the font throws: IOException - |
writeComment | protected void writeComment(String comment) throws IOException(Code) | | Writes some comment.
This method writes some comment.
Parameters: comment - the comment that has to be written throws: IOException - |
writeCssProperty | protected void writeCssProperty(String prop, String value) throws IOException(Code) | | Writes out a CSS property.
Parameters: prop - a CSS property Parameters: value - the value of the CSS property throws: IOException - |
writeHeader | protected void writeHeader(Meta meta) throws IOException(Code) | | Writes a Metatag in the header.
Parameters: meta - the element that has to be written throws: IOException - |
writeJavaScript | protected void writeJavaScript(Header header) throws IOException(Code) | | Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header.
Parameters: header - the element that has to be written throws: IOException - |
writeLink | protected void writeLink(Header header) throws IOException(Code) | | Writes a link in the header.
Parameters: header - the element that has to be written throws: IOException - |
writeSection | protected void writeSection(Section section, int indent) throws IOException(Code) | | Writes the HTML representation of a section.
Parameters: section - the section to write Parameters: indent - the indentation throws: IOException - |
|
|