java.lang.Object
org.openpdf.text.DocWriter
org.openpdf.text.html.HtmlWriter
- All Implemented Interfaces:
AutoCloseable,EventListener,DocListener,ElementListener
Deprecated.
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
FieldsModifier and TypeFieldDescriptionstatic final byte[]Deprecated.This is a possible HTML-tag.Deprecated.This is the current font of the HTML.static final byte[]Deprecated.This is a possible HTML-tag.protected HeaderFooterDeprecated.This is the textual part of the footerprotected HeaderFooterDeprecated.This is the textual part of a headerprotected StringDeprecated.This is a path for images.protected PropertiesDeprecated.Store the markup properties of a MarkedObject.static final StringDeprecated.This is a possible HTML-tag.protected intDeprecated.Stores the page number.protected FontDeprecated.This is the standard font of the HTML. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHtmlWriter(Document doc, OutputStream os) Deprecated.Constructs aHtmlWriter. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Signals that aStringwas added to theDocument.booleanDeprecated.Signals that anElementwas added to theDocument.voidclose()Deprecated.Signals that theDocumentwas closed and that no otherElementswill be added.static HtmlWritergetInstance(Document document, OutputStream os) Deprecated.Gets an instance of theHtmlWriter.protected voidDeprecated.Adds the header to the top of theDocumentprotected voidDeprecated.Adds the header to the top of theDocumentbooleanisOtherFont(Font font) Deprecated.Checks if a given font is the same as the font that was last used.booleannewPage()Deprecated.Signals that an new page has to be started.voidopen()Deprecated.Signals that theDocumenthas been opened and thatElementscan be added.voidDeprecated.Resets the imagepath.voidsetFooter(HeaderFooter footer) Deprecated.Changes the footer of this document.voidsetHeader(HeaderFooter header) Deprecated.Changes the header of this document.voidsetImagepath(String imagepath) Deprecated.Sets the basepath for images.voidsetStandardFont(Font standardfont) Deprecated.Changes the standardfont.protected voidDeprecated.Writes the HTML representation of an element.protected voidwrite(Font font, Properties styleAttributes) Deprecated.Writes the representation of aFont.protected voidwriteComment(String comment) Deprecated.Writes some comment.protected voidwriteCssProperty(String prop, String value) Deprecated.Writes out a CSS property.protected voidwriteHeader(Meta meta) Deprecated.Writes a Metatag in the header.protected voidwriteJavaScript(Header header) Deprecated.Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header.protected voidDeprecated.Writes a link in the header.protected voidwriteSection(Section section, int indent) Deprecated.Writes the HTML representation of a section.Methods inherited from class org.openpdf.text.DocWriter
addTabs, flush, getISOBytes, isCloseStream, isPaused, pause, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setMarginMirroring, setMarginMirroringTopBottom, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart
-
Field Details
-
BEGINCOMMENT
public static final byte[] BEGINCOMMENTDeprecated.This is a possible HTML-tag. -
ENDCOMMENT
public static final byte[] ENDCOMMENTDeprecated.This is a possible HTML-tag. -
NBSP
Deprecated.This is a possible HTML-tag.- See Also:
-
currentfont
Deprecated.This is the current font of the HTML. -
standardfont
Deprecated.This is the standard font of the HTML. -
imagepath
Deprecated.This is a path for images. -
pageN
protected int pageNDeprecated.Stores the page number. -
header
Deprecated.This is the textual part of a header -
markup
Deprecated.Store the markup properties of a MarkedObject.
-
-
Constructor Details
-
HtmlWriter
Deprecated.Constructs aHtmlWriter.- Parameters:
doc- TheDocumentthat has to be written as HTMLos- TheOutputStreamthe writer has to write to.
-
-
Method Details
-
getInstance
Deprecated.Gets an instance of theHtmlWriter.- Parameters:
document- TheDocumentthat has to be writtenos- TheOutputStreamthe writer has to write to.- Returns:
- a new
HtmlWriter
-
newPage
public boolean newPage()Deprecated.Signals that an new page has to be started.- Specified by:
newPagein interfaceDocListener- Overrides:
newPagein classDocWriter- Returns:
trueif this action succeeded,falseif not.
-
add
Deprecated.Signals that anElementwas added to theDocument.- Specified by:
addin interfaceElementListener- Overrides:
addin classDocWriter- Parameters:
element- a high level object that has to be translated to HTML- Returns:
trueif the element was added,falseif not.- Throws:
DocumentException- when a document isn't open yet, or has been closed
-
open
public void open()Deprecated.Signals that theDocumenthas been opened and thatElementscan be added.The
HEAD-section of the HTML-document is written.- Specified by:
openin interfaceDocListener- Overrides:
openin classDocWriter
-
close
public void close()Deprecated.Signals that theDocumentwas closed and that no otherElementswill be added.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDocListener- Overrides:
closein classDocWriter
-
initHeader
protected void initHeader()Deprecated.Adds the header to the top of theDocument -
writeHeader
Deprecated.Writes a Metatag in the header.- Parameters:
meta- the element that has to be written- Throws:
IOException- on error
-
writeLink
Deprecated.Writes a link in the header.- Parameters:
header- the element that has to be written- Throws:
IOException- on error
-
writeJavaScript
Deprecated.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- on error
-
writeComment
Deprecated.Writes some comment.This method writes some comment.
- Parameters:
comment- the comment that has to be written- Throws:
IOException- on error
-
setStandardFont
Deprecated.Changes the standardfont.- Parameters:
standardfont- The font
-
isOtherFont
Deprecated.Checks if a given font is the same as the font that was last used.- Parameters:
font- the font of an object- Returns:
- true if the font differs
-
setImagepath
Deprecated.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
-
resetImagepath
public void resetImagepath()Deprecated.Resets the imagepath. -
add
Deprecated.Signals that aStringwas added to theDocument.- Parameters:
string- a String to add to the HTML- Returns:
trueif the string was added,falseif not.
-
write
Deprecated.Writes the HTML representation of an element.- Parameters:
element- the elementindent- the indentation- Throws:
IOException- thrown when an I/O operation fails
-
writeSection
Deprecated.Writes the HTML representation of a section.- Parameters:
section- the section to writeindent- the indentation- Throws:
IOException- thrown when an I/O operation fails
-
write
Deprecated.Writes the representation of aFont.- Parameters:
font- aFontstyleAttributes- the style of the font- Throws:
IOException- thrown when an I/O operation fails
-
writeCssProperty
Deprecated.Writes out a CSS property.- Parameters:
prop- a CSS propertyvalue- the value of the CSS property- Throws:
IOException- thrown when an I/O operation fails
-