Class RtfWriter2
- Namespace
- iTextSharp.text.rtf
- Assembly
- iTextSharp.LGPLv2.Core.dll
The RtfWriter allows the creation of rtf documents via the iText system @author Mark Hall (Mark.Hall@mail.room3b.eu)
public class RtfWriter2 : DocWriter, IDocListener, IElementListener, IDisposable
- Inheritance
-
RtfWriter2
- Implements
- Inherited Members
Constructors
RtfWriter2(Document, Stream)
Constructs a new RtfWriter that listens to the specified Document and writes its output to the Stream.
protected RtfWriter2(Document doc, Stream os)
Parameters
Properties
Footer
Sets the footer to use
public override HeaderFooter Footer { set; }
Property Value
Header
Sets the header to use
public override HeaderFooter Header { set; }
Property Value
PageCount
This method is not supported in the RtfWriter
public override int PageCount { set; }
Property Value
Methods
Add(IElement)
Adds an Element to the Document @throws DocumentException
public override bool Add(IElement element)
Parameters
element
IElementThe element to be added
Returns
- bool
false
Close()
Closes the RtfDocument. This causes the document to be written to the specified Stream
public override void Close()
GetDocumentSettings()
Gets the RtfDocumentSettings that specify how the rtf document is generated.
public RtfDocumentSettings GetDocumentSettings()
Returns
- RtfDocumentSettings
The current RtfDocumentSettings.
GetInstance(Document, Stream)
Static method to generate RtfWriters
public static RtfWriter2 GetInstance(Document doc, Stream os)
Parameters
Returns
- RtfWriter2
The new RtfWriter
ImportRtfDocument(Stream)
Adds the complete RTF document to the current RTF document being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings. @throws IOException On errors reading the RTF document. @throws DocumentException On errors adding to this RTF document.
public void ImportRtfDocument(Stream documentSource)
Parameters
documentSource
StreamThe Stream to read the RTF document from.
ImportRtfDocument(Stream, IEventListener[])
Adds the complete RTF document to the current RTF document being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings. Uses new RtfParser object. @throws IOException @throws DocumentException @see com.lowagie.text.rtf.parser.RtfParser @see com.lowagie.text.rtf.parser.RtfParser#importRtfDocument(Reader, RtfDocument) @since 2.0.8 @author Howard Shank
public void ImportRtfDocument(Stream documentSource, IEventListener[] events)
Parameters
documentSource
StreamThe Stream to read the RTF document from.
events
IEventListener[]The array of event listeners. May be null
ImportRtfDocumentIntoElement(IElement, FileStream)
Adds the complete RTF document to the current RTF element being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings. @throws IOException On errors reading the RTF document. @throws DocumentException On errors adding to this RTF document. @since 2.1.4
public void ImportRtfDocumentIntoElement(IElement elem, FileStream documentSource)
Parameters
elem
IElementThe Element the RTF document is to be imported into.
documentSource
FileStreamThe Reader to read the RTF document from.
ImportRtfDocumentIntoElement(IElement, FileStream, IEventListener[])
Adds the complete RTF document to the current RTF element being generated. It will parse the font and color tables and correct the font and color references so that the imported RTF document retains its formattings. @throws IOException On errors reading the RTF document. @throws DocumentException On errors adding to this RTF document. @since 2.1.4
public void ImportRtfDocumentIntoElement(IElement elem, FileStream documentSource, IEventListener[] events)
Parameters
elem
IElementThe Element the RTF document is to be imported into.
documentSource
FileStreamThe Reader to read the RTF document from.
events
IEventListener[]The event array for listeners.
ImportRtfFragment(Stream, RtfImportMappings)
Adds a fragment of an RTF document to the current RTF document being generated. Since this fragment doesn't contain font or color tables, all fonts and colors are mapped to the default font and color. If the font and color mappings are known, they can be specified via the mappings parameter. @throws IOException On errors reading the RTF fragment. @throws DocumentException On errors adding to this RTF fragment.
public void ImportRtfFragment(Stream documentSource, RtfImportMappings mappings)
Parameters
documentSource
StreamThe Stream to read the RTF fragment from.
mappings
RtfImportMappingsThe RtfImportMappings that contain font and color mappings to apply to the fragment.
ImportRtfFragment(Stream, RtfImportMappings, IEventListener[])
Adds a fragment of an RTF document to the current RTF document being generated. Since this fragment doesn't contain font or color tables, all fonts and colors are mapped to the default font and color. If the font and color mappings are known, they can be specified via the mappings parameter. Uses new RtfParser object. @throws IOException On errors reading the RTF fragment. @throws DocumentException On errors adding to this RTF fragment. @see com.lowagie.text.rtf.parser.RtfImportMappings @see com.lowagie.text.rtf.parser.RtfParser @see com.lowagie.text.rtf.parser.RtfParser#importRtfFragment(Reader, RtfDocument, com.lowagie.text.rtf.parser.RtfImportMappings) @since 2.0.8 @author Howard Shank
public void ImportRtfFragment(Stream documentSource, RtfImportMappings mappings, IEventListener[] events)
Parameters
documentSource
StreamThe Stream to read the RTF fragment from.
mappings
RtfImportMappingsThe RtfImportMappings that contain font and color mappings to apply to the fragment.
events
IEventListener[]The array of event listeners. May be null
NewPage()
Adds a page break
public override bool NewPage()
Returns
- bool
false
Open()
Opens the RtfDocument
public override void Open()
ResetFooter()
Resets the footer
public override void ResetFooter()
ResetHeader()
Resets the header
public override void ResetHeader()
ResetPageCount()
This method is not supported in the RtfWriter
public override void ResetPageCount()
SetAutogenerateTocEntries(bool)
Whether to automagically generate table of contents entries when adding Chapters or Sections.
public void SetAutogenerateTocEntries(bool autogenerate)
Parameters
autogenerate
boolWhether to automatically generate TOC entries
SetMargins(float, float, float, float)
Sets the page margins
public override bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Parameters
marginLeft
floatThe left margin
marginRight
floatThe right margin
marginTop
floatThe top margin
marginBottom
floatThe bottom margin
Returns
- bool
false
SetPageSize(Rectangle)
Sets the size of the page
public override bool SetPageSize(Rectangle pageSize)
Parameters
pageSize
RectangleA Rectangle representing the page
Returns
- bool
false