The RtfWriter allows the creation of rtf documents via the iText system
Version: $Id: RtfWriter2.java 3440 2008-05-25 18:16:48Z howard_s $
| Method from com.lowagie.text.rtf.RtfWriter2 Detail: |
public boolean add(Element element) throws DocumentException {
if (pause) {
return false;
}
RtfBasicElement[] rtfElements = rtfDoc.getMapper().mapElement(element);
if(rtfElements.length != 0) {
for(int i = 0; i < rtfElements.length; i++) {
if(rtfElements[i] != null) {
rtfDoc.add(rtfElements[i]);
}
}
return true;
} else {
return false;
}
}
Adds an Element to the Document |
public void clearTextWrap() {
}
This method is not supported in the RtfWriter |
public void close() {
if (open) {
rtfDoc.writeDocument(os);
super.close();
this.rtfDoc = new RtfDocument();
}
}
Closes the RtfDocument. This causes the document to be written
to the specified OutputStream |
public RtfDocumentSettings getDocumentSettings() {
return this.rtfDoc.getDocumentSettings();
}
Gets the RtfDocumentSettings that specify how the rtf document is generated. |
public static RtfWriter2 getInstance(Document doc,
OutputStream os) {
return new RtfWriter2(doc, os);
}
Static method to generate RtfWriters |
public void importRtfDocument(FileInputStream documentSource) throws IOException, DocumentException {
importRtfDocument(documentSource, null);
}
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. |
public void importRtfDocument(InputStream documentSource,
EventListener[] events) throws IOException, DocumentException {
if(!this.open) {
throw new DocumentException("The document must be open to import RTF documents.");
}
RtfParser rtfImport = new RtfParser(this.document);
if(events != null) {
for(int idx=0;idx< events.length;idx++) {
rtfImport.addListener(events[idx]);
}
}
rtfImport.importRtfDocument(documentSource, this.rtfDoc);
}
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.
(author: Howard Shank) |
public void importRtfFragment(InputStream documentSource,
RtfImportMappings mappings) throws IOException, DocumentException {
importRtfFragment(documentSource, mappings, null);
}
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. |
public void importRtfFragment(InputStream documentSource,
RtfImportMappings mappings,
EventListener[] events) throws IOException, DocumentException {
if(!this.open) {
throw new DocumentException("The document must be open to import RTF fragments.");
}
RtfParser rtfImport = new RtfParser(this.document);
if(events != null) {
for(int idx=0;idx< events.length;idx++) {
rtfImport.addListener(events[idx]);
}
}
rtfImport.importRtfFragment(documentSource, this.rtfDoc, mappings);
}
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.
(author: Howard Shank) |
public boolean newPage() {
rtfDoc.add(new RtfNewPage(rtfDoc));
return true;
}
|
public void open() {
super.open();
this.rtfDoc.open();
}
|
public void resetFooter() {
this.rtfDoc.getDocumentHeader().setFooter(null);
}
|
public void resetHeader() {
this.rtfDoc.getDocumentHeader().setHeader(null);
}
|
public void resetPageCount() {
}
This method is not supported in the RtfWriter |
public void setAutogenerateTOCEntries(boolean autogenerate) {
this.rtfDoc.setAutogenerateTOCEntries(autogenerate);
}
Whether to automagically generate table of contents entries when
adding Chapters or Sections. |
public void setFooter(HeaderFooter hf) {
this.rtfDoc.getDocumentHeader().setFooter(hf);
}
|
public void setHeader(HeaderFooter hf) {
this.rtfDoc.getDocumentHeader().setHeader(hf);
}
|
public boolean setMargins(float left,
float right,
float top,
float bottom) {
rtfDoc.getDocumentHeader().getPageSetting().setMarginLeft((int) (left * RtfElement.TWIPS_FACTOR));
rtfDoc.getDocumentHeader().getPageSetting().setMarginRight((int) (right * RtfElement.TWIPS_FACTOR));
rtfDoc.getDocumentHeader().getPageSetting().setMarginTop((int) (top * RtfElement.TWIPS_FACTOR));
rtfDoc.getDocumentHeader().getPageSetting().setMarginBottom((int) (bottom * RtfElement.TWIPS_FACTOR));
return true;
}
|
public void setPageCount(int i) {
}
This method is not supported in the RtfWriter |
public boolean setPageSize(Rectangle rect) {
rtfDoc.getDocumentHeader().getPageSetting().setPageSize(rect);
return true;
}
Sets the size of the page |