HiraokaHyperTools.iTextSharp-LGPL  0.2.5
iTextSharp.text.Document Class Reference

A generic Document class. More...

Inheritance diagram for iTextSharp.text.Document:
iTextSharp.text.IDocListener iTextSharp.text.IElementListener iTextSharp.text.pdf.PdfDocument

Public Member Functions

 Document ()
 Constructs a new Document-object. More...
 
 Document (Rectangle pageSize)
 Constructs a new Document-object. More...
 
 Document (Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom)
 Constructs a new Document-object. More...
 
void AddDocListener (IDocListener listener)
 Adds a IDocListener to the Document. More...
 
void RemoveIDocListener (IDocListener listener)
 Removes a IDocListener from the Document. More...
 
virtual bool Add (IElement element)
 Adds an Element to the Document. More...
 
virtual void Open ()
 Opens the document. More...
 
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 bool NewPage ()
 Signals that an new page has to be started. 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 Close ()
 Closes the document. More...
 
bool AddHeader (string name, string content)
 Adds a user defined header to the document. More...
 
bool AddTitle (string title)
 Adds the title to a Document. More...
 
bool AddSubject (string subject)
 Adds the subject to a Document. More...
 
bool AddKeywords (string keywords)
 Adds the keywords to a Document. More...
 
bool AddAuthor (string author)
 Adds the author to a Document. More...
 
bool AddCreator (string creator)
 Adds the creator to a Document. More...
 
bool AddProducer ()
 Adds the producer to a Document. More...
 
bool AddCreationDate ()
 Adds the current date and time to a Document. More...
 
float GetLeft (float margin)
 Returns the lower left x-coordinate considering a given margin. More...
 
float GetRight (float margin)
 Returns the upper right x-coordinate, considering a given margin. More...
 
float GetTop (float margin)
 Returns the upper right y-coordinate, considering a given margin. More...
 
float GetBottom (float margin)
 Returns the lower left y-coordinate, considering a given margin. More...
 
bool IsOpen ()
 Checks if the document is open. More...
 
virtual bool SetMarginMirroring (bool marginMirroring)
 
virtual bool SetMarginMirroringTopBottom (bool marginMirroringTopBottom)
 
bool IsMarginMirroring ()
 

Static Public Attributes

static bool Compress = true
 summary> Scales the WMF font size. The default value is 0.86. More...
 
static float WmfFontCorrection = 0.86f
 summary> The IDocListener. More...
 

Protected Attributes

bool open
 summary> Has the document allready been closed? More...
 
bool close
 
Rectangle pageSize
 The size of the page. More...
 
float marginLeft = 0
 summary> margin in x direction starting from the right More...
 
float marginRight = 0
 summary> margin in y direction starting from the top More...
 
float marginTop = 0
 summary> margin in y direction starting from the bottom More...
 
float marginBottom = 0
 
bool marginMirroring = false
 
bool marginMirroringTopBottom = false
 summary> Content of JavaScript onLoad function More...
 
string javaScript_onLoad = null
 summary> Content of JavaScript onUnLoad function More...
 
string javaScript_onUnLoad = null
 summary> Style class in HTML body tag More...
 
string htmlStyleClass = null
 
int pageN = 0
 Current pagenumber More...
 
HeaderFooter header = null
 summary> This is the textual part of the footer More...
 
HeaderFooter footer = null
 
int chapternumber = 0
 

Properties

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...
 
int PageNumber [get]
 Returns the current page number. More...
 
float LeftMargin [get]
 Returns the left margin. More...
 
float RightMargin [get]
 Return the right margin. More...
 
float TopMargin [get]
 Returns the top margin. More...
 
float BottomMargin [get]
 Returns the bottom margin. More...
 
float Left [get]
 Returns the lower left x-coordinate. More...
 
float Right [get]
 Returns the upper right x-coordinate. More...
 
float Top [get]
 Returns the upper right y-coordinate. More...
 
float Bottom [get]
 Returns the lower left y-coordinate. More...
 
Rectangle PageSize [get]
 Gets the pagesize. More...
 
static String Product [get]
 
static String Release [get]
 
static string Version [get]
 Gets the iText version. More...
 
string JavaScript_onLoad [get, set]
 Gets the JavaScript onLoad command. More...
 
string JavaScript_onUnLoad [get, set]
 Gets the JavaScript onUnLoad command. More...
 
string HtmlStyleClass [get, set]
 Gets the style class of the HTML body tag More...
 
- 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 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.

  1. 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
<strong>Document document = new Document(PageSize.A4, 50, 50, 50, 50);</strong>
try {
// creation of the different writers
HtmlWriter.GetInstance(<strong>document</strong>, System.out);
PdfWriter.GetInstance(<strong>document</strong>, new FileOutputStream("text.pdf"));
// we add some meta information to the document
<strong>document.AddAuthor("Bruno Lowagie");
document.AddSubject("This is the result of a Test.");</strong>
// 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);
<strong>document.SetHeader(header);
document.SetFooter(footer);</strong>
// we open the document for writing
<strong>document.Open();
document.Add(new Paragraph("Hello world"));</strong>
}
catch (DocumentException de) {
Console.Error.WriteLine(de.Message);
}
<strong>document.Close();</strong>
Document()
Constructs a new Document-object.
Definition: Document.cs:187
Rectangle PageSize
Gets the pagesize.
Definition: Document.cs:614
HeaderFooter footer
Definition: Document.cs:174
HeaderFooter header
summary> This is the textual part of the footer
Definition: Document.cs:171
Definition: Dimension.cs:3

Constructor & Destructor Documentation

◆ Document() [1/3]

iTextSharp.text.Document.Document ( )

Constructs a new Document-object.

<overloads> Has three overloads. </overloads>

◆ Document() [2/3]

iTextSharp.text.Document.Document ( Rectangle  pageSize)

Constructs a new Document-object.

Parameters
pageSizethe pageSize

◆ Document() [3/3]

iTextSharp.text.Document.Document ( Rectangle  pageSize,
float  marginLeft,
float  marginRight,
float  marginTop,
float  marginBottom 
)

Constructs a new Document-object.

Parameters
pageSizethe pageSize
marginLeftthe margin on the left
marginRightthe margin on the right
marginTopthe margin on the top
marginBottomthe margin on the bottom

Member Function Documentation

◆ Add()

virtual bool iTextSharp.text.Document.Add ( IElement  element)
virtual

Adds an Element to the Document.

Parameters
elementthe Element to add
Returns
true if the element was added, false if not

Implements iTextSharp.text.IElementListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ AddAuthor()

bool iTextSharp.text.Document.AddAuthor ( string  author)

Adds the author to a Document.

Parameters
authorthe name of the author
Returns
true if successful, false otherwise

◆ AddCreationDate()

bool iTextSharp.text.Document.AddCreationDate ( )

Adds the current date and time to a Document.

Returns
true if successful, false otherwise

◆ AddCreator()

bool iTextSharp.text.Document.AddCreator ( string  creator)

Adds the creator to a Document.

Parameters
creatorthe name of the creator
Returns
true if successful, false otherwise

◆ AddDocListener()

void iTextSharp.text.Document.AddDocListener ( IDocListener  listener)

Adds a IDocListener to the Document.

Parameters
listenerthe new IDocListener

◆ AddHeader()

bool iTextSharp.text.Document.AddHeader ( string  name,
string  content 
)

Adds a user defined header to the document.

Parameters
namethe name of the header
contentthe content of the header
Returns
true if successful, false otherwise

◆ AddKeywords()

bool iTextSharp.text.Document.AddKeywords ( string  keywords)

Adds the keywords to a Document.

Parameters
keywordskeywords to add
Returns
true if successful, false otherwise

◆ AddProducer()

bool iTextSharp.text.Document.AddProducer ( )

Adds the producer to a Document.

Returns
true if successful, false otherwise

◆ AddSubject()

bool iTextSharp.text.Document.AddSubject ( string  subject)

Adds the subject to a Document.

Parameters
subjectthe subject
Returns
true if successful, false otherwise

◆ AddTitle()

bool iTextSharp.text.Document.AddTitle ( string  title)

Adds the title to a Document.

Parameters
titlethe title
Returns
true if successful, false otherwise

◆ Close()

virtual void iTextSharp.text.Document.Close ( )
virtual

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.

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ GetBottom()

float iTextSharp.text.Document.GetBottom ( float  margin)

Returns the lower left y-coordinate, considering a given margin.

Parameters
margina margin
Returns
the lower left y-coordinate

◆ GetLeft()

float iTextSharp.text.Document.GetLeft ( float  margin)

Returns the lower left x-coordinate considering a given margin.

Parameters
margina margin
Returns
the lower left x-coordinate

◆ GetRight()

float iTextSharp.text.Document.GetRight ( float  margin)

Returns the upper right x-coordinate, considering a given margin.

Parameters
margina margin
Returns
the upper right x-coordinate

◆ GetTop()

float iTextSharp.text.Document.GetTop ( float  margin)

Returns the upper right y-coordinate, considering a given margin.

Parameters
margina margin
Returns
the upper right y-coordinate

◆ IsMarginMirroring()

bool iTextSharp.text.Document.IsMarginMirroring ( )

Gets the margin mirroring flag.

Returns
the margin mirroring flag

◆ IsOpen()

bool iTextSharp.text.Document.IsOpen ( )

Checks if the document is open.

Returns
true if the document is open

◆ NewPage()

virtual bool iTextSharp.text.Document.NewPage ( )
virtual

Signals that an new page has to be started.

Returns
true if the page was added, false if not.

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ Open()

virtual void iTextSharp.text.Document.Open ( )
virtual

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.

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ RemoveIDocListener()

void iTextSharp.text.Document.RemoveIDocListener ( IDocListener  listener)

Removes a IDocListener from the Document.

Parameters
listenerthe IDocListener that has to be removed.

◆ ResetFooter()

virtual void iTextSharp.text.Document.ResetFooter ( )
virtual

Resets the footer of this document.

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ ResetHeader()

virtual void iTextSharp.text.Document.ResetHeader ( )
virtual

Resets the header of this document.

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ ResetPageCount()

virtual void iTextSharp.text.Document.ResetPageCount ( )
virtual

Sets the page number to 0.

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ SetMarginMirroring()

virtual bool iTextSharp.text.Document.SetMarginMirroring ( bool  marginMirroring)
virtual

Set the margin mirroring. It will mirror right/left margins for odd/even pages.

Note: it will not work with Table.

Parameters
marginMirroringtrue to mirror the margins
Returns
always true

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ SetMarginMirroringTopBottom()

virtual bool iTextSharp.text.Document.SetMarginMirroringTopBottom ( bool  marginMirroringTopBottom)
virtual

Set the margin mirroring. It will mirror top/bottom margins for odd/even pages.

Note: it will not work with Table.

Parameters
marginMirroringTopBottomtrue to mirror the margins
Returns
always true
Since
2.1.6

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ SetMargins()

virtual bool iTextSharp.text.Document.SetMargins ( float  marginLeft,
float  marginRight,
float  marginTop,
float  marginBottom 
)
virtual

Sets the margins.

Parameters
marginLeftthe margin on the left
marginRightthe margin on the right
marginTopthe margin on the top
marginBottomthe margin on the bottom
Returns

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

◆ SetPageSize()

virtual bool iTextSharp.text.Document.SetPageSize ( Rectangle  pageSize)
virtual

Sets the pagesize.

Parameters
pageSizethe new pagesize
Returns
a bool

Implements iTextSharp.text.IDocListener.

Reimplemented in iTextSharp.text.pdf.PdfDocument.

Member Data Documentation

◆ chapternumber

int iTextSharp.text.Document.chapternumber = 0
protected

This is a chapter number in case ChapterAutoNumber is used.

◆ close

bool iTextSharp.text.Document.close
protected

◆ Compress

bool iTextSharp.text.Document.Compress = true
static

summary> Scales the WMF font size. The default value is 0.86.

◆ footer

HeaderFooter iTextSharp.text.Document.footer = null
protected

◆ header

HeaderFooter iTextSharp.text.Document.header = null
protected

summary> This is the textual part of the footer

◆ htmlStyleClass

string iTextSharp.text.Document.htmlStyleClass = null
protected

◆ javaScript_onLoad

string iTextSharp.text.Document.javaScript_onLoad = null
protected

summary> Content of JavaScript onUnLoad function

◆ javaScript_onUnLoad

string iTextSharp.text.Document.javaScript_onUnLoad = null
protected

summary> Style class in HTML body tag

◆ marginBottom

float iTextSharp.text.Document.marginBottom = 0
protected

◆ marginLeft

float iTextSharp.text.Document.marginLeft = 0
protected

summary> margin in x direction starting from the right

◆ marginMirroring

bool iTextSharp.text.Document.marginMirroring = false
protected

◆ marginMirroringTopBottom

bool iTextSharp.text.Document.marginMirroringTopBottom = false
protected

summary> Content of JavaScript onLoad function

mirroring of the top/bottom margins

Since
2.1.6

◆ marginRight

float iTextSharp.text.Document.marginRight = 0
protected

summary> margin in y direction starting from the top

◆ marginTop

float iTextSharp.text.Document.marginTop = 0
protected

summary> margin in y direction starting from the bottom

◆ open

bool iTextSharp.text.Document.open
protected

summary> Has the document allready been closed?

◆ pageN

int iTextSharp.text.Document.pageN = 0
protected

Current pagenumber

summary> This is the textual part of a Page; it can contain a header

◆ pageSize

Rectangle iTextSharp.text.Document.pageSize
protected

The size of the page.

summary> margin in x direction starting from the left

◆ WmfFontCorrection

float iTextSharp.text.Document.WmfFontCorrection = 0.86f
static

summary> The IDocListener.

Property Documentation

◆ Bottom

float iTextSharp.text.Document.Bottom
get

Returns the lower left y-coordinate.

the lower left y-coordinate.

◆ BottomMargin

float iTextSharp.text.Document.BottomMargin
get

Returns the bottom margin.

the bottom margin

◆ Footer

virtual HeaderFooter iTextSharp.text.Document.Footer
set

Changes the footer of this document.

a HeaderFooter

◆ Header

virtual HeaderFooter iTextSharp.text.Document.Header
set

Changes the header of this document.

a HeaderFooter

◆ HtmlStyleClass

string iTextSharp.text.Document.HtmlStyleClass
getset

Gets the style class of the HTML body tag

the style class of the HTML body tag

◆ JavaScript_onLoad

string iTextSharp.text.Document.JavaScript_onLoad
getset

Gets the JavaScript onLoad command.

the JavaScript onLoad command.

◆ JavaScript_onUnLoad

string iTextSharp.text.Document.JavaScript_onUnLoad
getset

Gets the JavaScript onUnLoad command.

the JavaScript onUnLoad command

◆ Left

float iTextSharp.text.Document.Left
get

Returns the lower left x-coordinate.

the lower left x-coordinate

◆ LeftMargin

float iTextSharp.text.Document.LeftMargin
get

Returns the left margin.

the left margin

◆ PageCount

virtual int iTextSharp.text.Document.PageCount
set

Sets the page number.

an int

◆ PageNumber

int iTextSharp.text.Document.PageNumber
get

Returns the current page number.

an int

◆ PageSize

Rectangle iTextSharp.text.Document.PageSize
get

Gets the pagesize.

the page size

◆ Product

String iTextSharp.text.Document.Product
staticget

Gets the product name. This method may only be changed by Paulo Soares and/or Bruno Lowagie.

Returns
the product name
Since
2.1.6

◆ Release

String iTextSharp.text.Document.Release
staticget

Gets the release number. This method may only be changed by Paulo Soares and/or Bruno Lowagie.

Returns
the product name
Since
2.1.6

◆ Right

float iTextSharp.text.Document.Right
get

Returns the upper right x-coordinate.

the upper right x-coordinate.

◆ RightMargin

float iTextSharp.text.Document.RightMargin
get

Return the right margin.

the right margin

◆ Top

float iTextSharp.text.Document.Top
get

Returns the upper right y-coordinate.

the upper right y-coordinate.

◆ TopMargin

float iTextSharp.text.Document.TopMargin
get

Returns the top margin.

the top margin

◆ Version

string iTextSharp.text.Document.Version
staticget

Gets the iText version.

iText version


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