HiraokaHyperTools.iTextSharp-LGPL  0.2.5
iTextSharp.text.html.HtmlWriter Class Reference
Inheritance diagram for iTextSharp.text.html.HtmlWriter:
iTextSharp.text.DocWriter iTextSharp.text.IDocListener iTextSharp.text.IElementListener

Public Member Functions

override bool NewPage ()
 
override bool Add (IElement element)
 
override void Open ()
 
override void Close ()
 
void SetStandardFont (Font standardFont)
 
bool IsOtherFont (Font font)
 
void SetImagepath (String imagepath)
 
void ResetImagepath ()
 
void SetHeader (HeaderFooter header)
 
void SetFooter (HeaderFooter footer)
 
bool Add (String str)
 
- Public Member Functions inherited from iTextSharp.text.DocWriter
virtual bool SetPageSize (Rectangle pageSize)
 Sets the pagesize. More...
 
virtual bool SetMargins (float marginLeft, float marginRight, float marginTop, float marginBottom)
 Sets the margins. More...
 
virtual void ResetHeader ()
 Resets the header of this document. More...
 
virtual void ResetFooter ()
 Resets the footer of this document. More...
 
virtual void ResetPageCount ()
 Sets the page number to 0. More...
 
virtual void Pause ()
 Let the writer know that all writing has to be paused. More...
 
bool IsPaused ()
 
virtual void Resume ()
 Let the writer know that writing may be resumed. More...
 
virtual void Flush ()
 Flushes the Stream. More...
 
virtual bool SetMarginMirroring (bool marginMirroring)
 
virtual bool SetMarginMirroringTopBottom (bool MarginMirroring)
 

Static Public Member Functions

static HtmlWriter GetInstance (Document document, Stream os)
 
- Static Public Member Functions inherited from iTextSharp.text.DocWriter
static byte[] GetISOBytes (string text)
 Converts a string into a Byte array according to the ISO-8859-1 codepage. More...
 

Static Public Attributes

static byte[] BEGINCOMMENT = GetISOBytes("<!-- ")
 
static byte[] ENDCOMMENT = GetISOBytes(" -->")
 
const string NBSP = "&nbsp;"
 
- Static Public Attributes inherited from iTextSharp.text.DocWriter
const byte NEWLINE = (byte)'\n'
 This is some byte that is often used. More...
 
const byte TAB = (byte)'\t'
 This is some byte that is often used. More...
 
const byte LT = (byte)'<'
 This is some byte that is often used. More...
 
const byte SPACE = (byte)' '
 This is some byte that is often used. More...
 
const byte EQUALS = (byte)'='
 This is some byte that is often used. More...
 
const byte QUOTE = (byte)'\"'
 This is some byte that is often used. More...
 
const byte GT = (byte)'>'
 This is some byte that is often used. More...
 
const byte FORWARD = (byte)'/'
 This is some byte that is often used. More...
 

Protected Member Functions

 HtmlWriter (Document doc, Stream os)
 
void InitHeader ()
 
void InitFooter ()
 
void WriteHeader (Meta meta)
 
void WriteLink (Header header)
 
void WriteJavaScript (Header header)
 
void WriteComment (String comment)
 
void Write (IElement element, int indent)
 
void WriteSection (Section section, int indent)
 
void Write (Font font, Properties styleAttributes)
 
void WriteCssProperty (String prop, String value)
 
- Protected Member Functions inherited from iTextSharp.text.DocWriter
 DocWriter ()
 
 DocWriter (Document document, Stream os)
 Constructs a DocWriter. More...
 
void Write (string str)
 Writes a string to the stream. More...
 
void AddTabs (int indent)
 Writes a number of tabs. More...
 
void Write (string key, string value)
 Writes a key-value pair to the stream. More...
 
void WriteStart (string tag)
 Writes a starttag to the stream. More...
 
void WriteEnd (string tag)
 Writes an endtag to the stream. More...
 
void WriteEnd ()
 Writes an endtag to the stream. More...
 
bool WriteMarkupAttributes (Properties markup)
 Writes the markup attributes of the specified MarkupAttributes object to the stream. More...
 

Protected Attributes

Stack currentfont = new Stack()
 
Font standardfont = new Font()
 
String imagepath = null
 
int pageN = 0
 
HeaderFooter header = null
 
HeaderFooter footer = null
 
Properties markup = new Properties()
 
- Protected Attributes inherited from iTextSharp.text.DocWriter
Rectangle pageSize
 The pageSize. More...
 
Document document
 This is the document that has to be written. More...
 
OutputStreamCounter os
 The stream of this writer. More...
 
bool open = false
 Is the writer open for writing? More...
 
bool pause = false
 Do we have to pause all writing actions? More...
 
bool closeStream = true
 

Additional Inherited Members

- Properties inherited from iTextSharp.text.DocWriter
virtual HeaderFooter Header [set]
 Changes the header of this document. More...
 
virtual HeaderFooter Footer [set]
 Changes the footer of this document. More...
 
virtual int PageCount [set]
 Sets the page number. More...
 
virtual bool CloseStream [get, set]
 
- Properties inherited from iTextSharp.text.IDocListener
int PageCount [set]
 Sets the page number. More...
 
HeaderFooter Header [set]
 Changes the header of this document. More...
 
HeaderFooter Footer [set]
 Changes the footer of this document. More...
 

Detailed Description

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 Stream 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 Stream
   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 Stream 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();

Constructor & Destructor Documentation

◆ HtmlWriter()

iTextSharp.text.html.HtmlWriter.HtmlWriter ( Document  doc,
Stream  os 
)
protected

Constructs a HtmlWriter.

Parameters
docThe Document that has to be written as HTML
osThe Stream the writer has to write to.

Member Function Documentation

◆ Add() [1/2]

override bool iTextSharp.text.html.HtmlWriter.Add ( IElement  element)
virtual

Signals that an Element was added to the Document.

Returns
true if the element was added, false if not.
Exceptions
DocumentExceptionwhen a document isn't open yet, or has been closed

Reimplemented from iTextSharp.text.DocWriter.

◆ Add() [2/2]

bool iTextSharp.text.html.HtmlWriter.Add ( String  str)

Signals that a String was added to the Document.

Returns
true if the string was added, false if not.
Exceptions
DocumentExceptionwhen a document isn't open yet, or has been closed

◆ Close()

override void iTextSharp.text.html.HtmlWriter.Close ( )
virtual

Signals that the Document was closed and that no other Elements will be added.

Reimplemented from iTextSharp.text.DocWriter.

◆ GetInstance()

static HtmlWriter iTextSharp.text.html.HtmlWriter.GetInstance ( Document  document,
Stream  os 
)
static

Gets an instance of the HtmlWriter.

Parameters
documentThe Document that has to be written
osThe Stream the writer has to write to.
Returns
a new HtmlWriter

◆ InitFooter()

void iTextSharp.text.html.HtmlWriter.InitFooter ( )
protected

Adds the header to the top of the Document

◆ InitHeader()

void iTextSharp.text.html.HtmlWriter.InitHeader ( )
protected

Adds the header to the top of the Document

◆ IsOtherFont()

bool iTextSharp.text.html.HtmlWriter.IsOtherFont ( Font  font)

Checks if a given font is the same as the font that was last used.

Parameters
fontthe font of an object
Returns
true if the font differs

◆ NewPage()

override bool iTextSharp.text.html.HtmlWriter.NewPage ( )
virtual

Signals that an new page has to be started.

Returns
true if this action succeeded, false if not.
Exceptions
DocumentExceptionwhen a document isn't open yet, or has been closed

Reimplemented from iTextSharp.text.DocWriter.

◆ Open()

override void iTextSharp.text.html.HtmlWriter.Open ( )
virtual

Signals that the Document has been opened and that Elements can be added.

The HEAD-section of the HTML-document is written.

Reimplemented from iTextSharp.text.DocWriter.

◆ ResetImagepath()

void iTextSharp.text.html.HtmlWriter.ResetImagepath ( )

Resets the imagepath.

◆ SetFooter()

void iTextSharp.text.html.HtmlWriter.SetFooter ( HeaderFooter  footer)

Changes the footer of this document.

Parameters
footerthe new footer

◆ SetHeader()

void iTextSharp.text.html.HtmlWriter.SetHeader ( HeaderFooter  header)

Changes the header of this document.

Parameters
headerthe new header

◆ SetImagepath()

void iTextSharp.text.html.HtmlWriter.SetImagepath ( String  imagepath)

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
imagepaththe new imagepath

◆ SetStandardFont()

void iTextSharp.text.html.HtmlWriter.SetStandardFont ( Font  standardFont)

Changes the standardfont.

Parameters
standardFontThe font

◆ Write() [1/2]

void iTextSharp.text.html.HtmlWriter.Write ( Font  font,
Properties  styleAttributes 
)
protected

Writes the representation of a Font.

Parameters
fonta Font
styleAttributesthe style of the font

◆ Write() [2/2]

void iTextSharp.text.html.HtmlWriter.Write ( IElement  element,
int  indent 
)
protected

Writes the HTML representation of an element.

Parameters
elementthe element
indentthe indentation

◆ WriteComment()

void iTextSharp.text.html.HtmlWriter.WriteComment ( String  comment)
protected

Writes some comment.

This method writes some comment.

Parameters
commentthe comment that has to be written
Exceptions
IOException

◆ WriteCssProperty()

void iTextSharp.text.html.HtmlWriter.WriteCssProperty ( String  prop,
String  value 
)
protected

Writes out a CSS property.

◆ WriteHeader()

void iTextSharp.text.html.HtmlWriter.WriteHeader ( Meta  meta)
protected

Writes a Metatag in the header.

Parameters
metathe element that has to be written
Exceptions
IOException

◆ WriteJavaScript()

void iTextSharp.text.html.HtmlWriter.WriteJavaScript ( Header  header)
protected

Writes a JavaScript section or, if the markup attribute HtmlTags.URL is set, a JavaScript reference in the header.

Parameters
headerthe element that has to be written
Exceptions
IOException

◆ WriteLink()

void iTextSharp.text.html.HtmlWriter.WriteLink ( Header  header)
protected

Writes a link in the header.

Parameters
headerthe element that has to be written
Exceptions
IOException

◆ WriteSection()

void iTextSharp.text.html.HtmlWriter.WriteSection ( Section  section,
int  indent 
)
protected

Writes the HTML representation of a section.

Parameters
sectionthe section to write
indentthe indentation

Member Data Documentation

◆ BEGINCOMMENT

byte [] iTextSharp.text.html.HtmlWriter.BEGINCOMMENT = GetISOBytes("<!-- ")
static

This is a possible HTML-tag.

◆ currentfont

Stack iTextSharp.text.html.HtmlWriter.currentfont = new Stack()
protected

This is the current font of the HTML.

◆ ENDCOMMENT

byte [] iTextSharp.text.html.HtmlWriter.ENDCOMMENT = GetISOBytes(" -->")
static

This is a possible HTML-tag.

◆ footer

HeaderFooter iTextSharp.text.html.HtmlWriter.footer = null
protected

This is the textual part of the footer

◆ header

HeaderFooter iTextSharp.text.html.HtmlWriter.header = null
protected

This is the textual part of a header

◆ imagepath

String iTextSharp.text.html.HtmlWriter.imagepath = null
protected

This is a path for images.

◆ markup

Properties iTextSharp.text.html.HtmlWriter.markup = new Properties()
protected

Store the markup properties of a MarkedObject.

◆ NBSP

const string iTextSharp.text.html.HtmlWriter.NBSP = "&nbsp;"
static

This is a possible HTML-tag.

◆ pageN

int iTextSharp.text.html.HtmlWriter.pageN = 0
protected

Stores the page number.

◆ standardfont

Font iTextSharp.text.html.HtmlWriter.standardfont = new Font()
protected

This is the standard font of the HTML.


The documentation for this class was generated from the following file: