Document Public class
Description
A generic Document class.
Diagram
flowchart LR classDef interfaceStyle stroke-dasharray: 5 5; classDef abstractStyle stroke-width:4px subgraph iTextSharp.text iTextSharp.text.Document[[Document]] iTextSharp.text.IDocListener[[IDocListener]] class iTextSharp.text.IDocListener interfaceStyle; iTextSharp.text.IElementListener[[IElementListener]] class iTextSharp.text.IElementListener interfaceStyle; end subgraph System System.IDisposable[[IDisposable]] end subgraph iTextSharp.text.pdf.interfaces iTextSharp.text.pdf.interfaces.IAccessibleElement[[IAccessibleElement]] class iTextSharp.text.pdf.interfaces.IAccessibleElement interfaceStyle; end iTextSharp.text.IDocListener --> iTextSharp.text.Document iTextSharp.text.IElementListener --> iTextSharp.text.IDocListener System.IDisposable --> iTextSharp.text.IDocListener iTextSharp.text.pdf.interfaces.IAccessibleElement --> iTextSharp.text.Document
Members
Properties
Public properties
|
Type |
Name |
Methods |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
Public methods
|
Returns |
Name |
|---|---|
|
|
(
element)
|
|
|
( |
|
|
()
|
|
|
( |
|
|
(
listener)
|
|
|
( |
|
|
( |
|
|
( |
|
|
()
|
|
|
( |
|
|
( |
|
|
()
|
|
|
()
|
|
|
() |
|
|
(
key) |
|
,
> |
() |
|
|
( |
|
|
( |
|
|
( |
|
|
( |
|
|
() |
|
|
()
|
|
|
()
|
|
|
()
|
|
|
()
|
|
|
(
listener)
|
|
|
()
|
|
|
(
key,
value) |
|
|
( |
|
|
( |
|
|
( |
|
|
(
pageSize)
|
Details
Summary
A generic Document class.
Remarks
All kinds of Text-elements can be added to a HTMLDocument. The Document signals all the listeners when an element has been added. 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.
Example
// creation of the document with a certain size and certain margins Document document = new Document(PageSize.A4, 50, 50, 50, 50); try { // creation of the different writers HtmlWriter.GetInstance(document, System.out); PdfWriter.GetInstance(document, new FileOutputStream("text.pdf")); // we add some meta information to the document document.AddAuthor("Bruno Lowagie"); document.AddSubject("This is the result of a Test."); // 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); document.SetHeader(header); document.SetFooter(footer); // we open the document for writing document.Open(); document.Add(new Paragraph("Hello world")); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } document.Close();
Inheritance
-
IDocListener -
IElementListener -
IDisposable -
IAccessibleElement
Constructors
Document [1/3]
Source code
public Document()
Summary
Constructs a new Document-object.
Document [2/3]
Source code
public Document(Rectangle pageSize)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
pageSize |
the pageSize |
Summary
Constructs a new Document-object.
Document [3/3]
Source code
public Document(Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
pageSize |
the pageSize |
|
|
marginLeft |
the margin on the left |
|
|
marginRight |
the margin on the right |
|
|
marginTop |
the margin on the top |
|
|
marginBottom |
the margin on the bottom |
Summary
Constructs a new Document-object.
Methods
AddDocListener
Source code
public virtual void AddDocListener(IDocListener listener)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
listener |
the new IDocListener |
Summary
Adds a IDocListener to the Document.
RemoveIDocListener
Source code
public virtual void RemoveIDocListener(IDocListener listener)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
listener |
the IDocListener that has to be removed. |
Summary
Removes a IDocListener from the Document.
Add
Source code
public virtual bool Add(IElement element)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
element |
the Element to add |
Summary
Adds an Element to the Document.
Returns
true if the element was added, false if not
Open
Source code
public virtual void Open()
Summary
Opens the document.
Remarks
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.
OpenDocument
Source code
public virtual void OpenDocument()
Summary
Opens the document.
Remarks
Version for languages that are not case-dependant. 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.
SetPageSize
Source code
public virtual bool SetPageSize(Rectangle pageSize)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
pageSize |
the new pagesize |
Summary
Sets the pagesize.
Returns
a bool
SetMargins
Source code
public virtual bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
marginLeft |
the margin on the left |
|
|
marginRight |
the margin on the right |
|
|
marginTop |
the margin on the top |
|
|
marginBottom |
the margin on the bottom |
Summary
Sets the margins.
Returns
NewPage
Source code
public virtual bool NewPage()
Summary
Signals that an new page has to be started.
Returns
true if the page was added, false if not.
ResetPageCount
Source code
public virtual void ResetPageCount()
Summary
Sets the page number to 0.
Close
Source code
public virtual void Close()
Summary
Closes the document.
Remarks
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.
CloseDocument
Source code
public virtual void CloseDocument()
Summary
Closes the document.
Remarks
Version for languages that are not case-dependant. 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.
AddHeader
Source code
public virtual bool AddHeader(string name, string content)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
name |
the name of the header |
|
|
content |
the content of the header |
Summary
Adds a user defined header to the document.
Returns
true if successful, false otherwise
AddTitle
Source code
public virtual bool AddTitle(string title)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
title |
the title |
Summary
Adds the title to a Document.
Returns
true if successful, false otherwise
AddSubject
Source code
public virtual bool AddSubject(string subject)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
subject |
the subject |
Summary
Adds the subject to a Document.
Returns
true if successful, false otherwise
AddKeywords
Source code
public virtual bool AddKeywords(string keywords)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
keywords |
keywords to add |
Summary
Adds the keywords to a Document.
Returns
true if successful, false otherwise
AddAuthor
Source code
public virtual bool AddAuthor(string author)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
author |
the name of the author |
Summary
Adds the author to a Document.
Returns
true if successful, false otherwise
AddCreator
Source code
public virtual bool AddCreator(string creator)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
creator |
the name of the creator |
Summary
Adds the creator to a Document.
Returns
true if successful, false otherwise
AddProducer
Source code
public virtual bool AddProducer()
Summary
Adds the producer to a Document.
Returns
true if successful, false otherwise
AddLanguage
Source code
public virtual bool AddLanguage(string language)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
language |
AddCreationDate
Source code
public virtual bool AddCreationDate()
Summary
Adds the current date and time to a Document.
Returns
true if successful, false otherwise
GetLeft
Source code
public virtual float GetLeft(float margin)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
margin |
a margin |
Summary
Returns the lower left x-coordinate considering a given margin.
Returns
the lower left x-coordinate
GetRight
Source code
public virtual float GetRight(float margin)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
margin |
a margin |
Summary
Returns the upper right x-coordinate, considering a given margin.
Returns
the upper right x-coordinate
GetTop
Source code
public virtual float GetTop(float margin)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
margin |
a margin |
Summary
Returns the upper right y-coordinate, considering a given margin.
Returns
the upper right y-coordinate
GetBottom
Source code
public virtual float GetBottom(float margin)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
margin |
a margin |
Summary
Returns the lower left y-coordinate, considering a given margin.
Returns
the lower left y-coordinate
IsOpen
Source code
public virtual bool IsOpen()
Summary
Checks if the document is open.
Returns
true if the document is open
SetMarginMirroring
Source code
public virtual bool SetMarginMirroring(bool marginMirroring)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
marginMirroring |
SetMarginMirroringTopBottom
Source code
public virtual bool SetMarginMirroringTopBottom(bool marginMirroringTopBottom)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
marginMirroringTopBottom |
IsMarginMirroring
Source code
public virtual bool IsMarginMirroring()
Dispose
Source code
public virtual void Dispose()
GetAccessibleAttribute
Source code
public virtual PdfObject GetAccessibleAttribute(PdfName key)
Arguments
|
Type |
Name |
Description |
|---|---|---|
|
|
key |
SetAccessibleAttribute
Source code
public virtual void SetAccessibleAttribute(PdfName key, PdfObject value)
Arguments
GetAccessibleAttributes
Source code
public virtual Dictionary<PdfName, PdfObject> GetAccessibleAttributes()
Properties
PageCount
public virtual int PageCount { set; }
Summary
Sets the page number.
Value
an int
PageNumber
public virtual int PageNumber { get; }
Summary
Returns the current page number.
Value
an int
LeftMargin
public virtual float LeftMargin { get; }
Summary
Returns the left margin.
Value
the left margin
RightMargin
public virtual float RightMargin { get; }
Summary
Return the right margin.
Value
the right margin
TopMargin
public virtual float TopMargin { get; }
Summary
Returns the top margin.
Value
the top margin
BottomMargin
public virtual float BottomMargin { get; }
Summary
Returns the bottom margin.
Value
the bottom margin
Left
public virtual float Left { get; }
Summary
Returns the lower left x-coordinate.
Value
the lower left x-coordinate
Right
public virtual float Right { get; }
Summary
Returns the upper right x-coordinate.
Value
the upper right x-coordinate.
Top
public virtual float Top { get; }
Summary
Returns the upper right y-coordinate.
Value
the upper right y-coordinate.
Bottom
public virtual float Bottom { get; }
Summary
Returns the lower left y-coordinate.
Value
the lower left y-coordinate.
PageSize
public virtual Rectangle PageSize { get; }
Summary
Gets the pagesize.
Value
the page size
JavaScript_onLoad
public virtual string JavaScript_onLoad { get; set; }
Summary
Gets the JavaScript onLoad command.
Value
the JavaScript onLoad command.
JavaScript_onUnLoad
public virtual string JavaScript_onUnLoad { get; set; }
Summary
Gets the JavaScript onUnLoad command.
Value
the JavaScript onUnLoad command
HtmlStyleClass
public virtual string HtmlStyleClass { get; set; }
Summary
Gets the style class of the HTML body tag
Value
the style class of the HTML body tag
Role
public virtual PdfName Role { get; set; }
ID
public virtual AccessibleElementId ID { get; set; }
IsInline
public virtual bool IsInline { get; }
Generated with ModularDoc