| Constructor: |
public RtfHeaderFooter(Element element) {
this(new Element[]{element});
}
Constructs a RtfHeaderFooter for any Element. Parameters:
element - The Element to display as content of this RtfHeaderFooter
|
public RtfHeaderFooter(Element[] elements) {
super(new Phrase(""), false);
this.content = new Object[elements.length];
for(int i = 0; i < elements.length; i++) {
this.content[i] = elements[i];
}
}
Constructs a RtfHeaderFooter for an array of Elements. Parameters:
elements - The Elements to display as the content of this RtfHeaderFooter.
|
protected RtfHeaderFooter(RtfDocument doc,
HeaderFooter headerFooter) {
super(new Phrase(""), false);
this.document = doc;
Paragraph par = new Paragraph();
par.setAlignment(headerFooter.alignment());
if (headerFooter.getBefore() != null) {
par.add(headerFooter.getBefore());
}
if (headerFooter.isNumbered()) {
par.add(new RtfPageNumber(this.document));
}
if (headerFooter.getAfter() != null) {
par.add(headerFooter.getAfter());
}
try {
this.content = new Object[1];
this.content[0] = doc.getMapper().mapElement(par)[0];
((RtfBasicElement) this.content[0]).setInHeader(true);
} catch(DocumentException de) {
de.printStackTrace();
}
}
Constructs a RtfHeaderFooter for a HeaderFooter. Parameters:
doc - The RtfDocument this RtfHeaderFooter belongs to
headerFooter - The HeaderFooter to base this RtfHeaderFooter on
|
protected RtfHeaderFooter(RtfDocument doc,
RtfHeaderFooter headerFooter,
int displayAt) {
super(new Phrase(""), false);
this.document = doc;
this.content = headerFooter.getContent();
this.displayAt = displayAt;
for(int i = 0; i < this.content.length; i++) {
if(this.content[i] instanceof Element) {
try {
this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0];
} catch(DocumentException de) {
de.printStackTrace();
}
}
if(this.content[i] instanceof RtfBasicElement) {
((RtfBasicElement) this.content[i]).setInHeader(true);
}
}
}
Constructs a RtfHeaderFooter as a copy of an existing RtfHeaderFooter.
For internal use only. Parameters:
doc - The RtfDocument this RtfHeaderFooter belongs to
headerFooter - The RtfHeaderFooter to copy
displayAt - The display location of this RtfHeaderFooter
|
protected RtfHeaderFooter(RtfDocument doc,
HeaderFooter headerFooter,
int type,
int displayAt) {
super(new Phrase(""), false);
this.document = doc;
this.type = type;
this.displayAt = displayAt;
Paragraph par = new Paragraph();
par.setAlignment(headerFooter.alignment());
if (headerFooter.getBefore() != null) {
par.add(headerFooter.getBefore());
}
if (headerFooter.isNumbered()) {
par.add(new RtfPageNumber(this.document));
}
if (headerFooter.getAfter() != null) {
par.add(headerFooter.getAfter());
}
try {
this.content = new Object[1];
if(this.document != null) {
this.content[0] = this.document.getMapper().mapElement(par)[0];
((RtfBasicElement) this.content[0]).setInHeader(true);
} else {
this.content[0] = par;
}
} catch(DocumentException de) {
de.printStackTrace();
}
}
Constructs a RtfHeaderFooter based on a HeaderFooter with a certain type and displayAt
location. For internal use only. Parameters:
doc - The RtfDocument this RtfHeaderFooter belongs to
headerFooter - The HeaderFooter to base this RtfHeaderFooter on
type - The type of RtfHeaderFooter
displayAt - The display location of this RtfHeaderFooter
|
| Method from com.lowagie.text.rtf.headerfooter.RtfHeaderFooter Detail: |
public void setAlignment(int alignment) {
super.setAlignment(alignment);
for(int i = 0; i < this.content.length; i++) {
if(this.content[i] instanceof Paragraph) {
((Paragraph) this.content[i]).setAlignment(alignment);
} else if(this.content[i] instanceof Table) {
((Table) this.content[i]).setAlignment(alignment);
} else if(this.content[i] instanceof Image) {
((Image) this.content[i]).setAlignment(alignment);
}
}
}
Set the alignment of this RtfHeaderFooter. Passes the setting
on to the contained element. |
public void setDisplayAt(int displayAt) {
this.displayAt = displayAt;
}
Sets the display location of this RtfHeaderFooter |
public void setInHeader(boolean inHeader) {
}
|
public void setInTable(boolean inTable) {
}
|
public void setRtfDocument(RtfDocument doc) {
this.document = doc;
if(this.document != null) {
for(int i = 0; i < this.content.length; i++) {
try {
if(this.content[i] instanceof Element) {
this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0];
((RtfBasicElement) this.content[i]).setInHeader(true);
} else if(this.content[i] instanceof RtfBasicElement){
((RtfBasicElement) this.content[i]).setRtfDocument(this.document);
((RtfBasicElement) this.content[i]).setInHeader(true);
}
} catch(DocumentException de) {
de.printStackTrace();
}
}
}
}
Sets the RtfDocument this RtfElement belongs to |
public void setType(int type) {
this.type = type;
}
Sets the type of this RtfHeaderFooter |
public void writeContent(OutputStream result) throws IOException {
result.write(OPEN_GROUP);
if(this.type == TYPE_HEADER) {
if(this.displayAt == DISPLAY_ALL_PAGES) {
result.write(HEADER_ALL);
} else if(this.displayAt == DISPLAY_FIRST_PAGE) {
result.write(HEADER_FIRST);
} else if(this.displayAt == DISPLAY_LEFT_PAGES) {
result.write(HEADER_LEFT);
} else if(this.displayAt == DISPLAY_RIGHT_PAGES) {
result.write(HEADER_RIGHT);
}
} else {
if(this.displayAt == DISPLAY_ALL_PAGES) {
result.write(FOOTER_ALL);
} else if(this.displayAt == DISPLAY_FIRST_PAGE) {
result.write(FOOTER_FIRST);
} else if(this.displayAt == DISPLAY_LEFT_PAGES) {
result.write(FOOTER_LEFT);
} else if(this.displayAt == DISPLAY_RIGHT_PAGES) {
result.write(FOOTER_RIGHT);
}
}
result.write(DELIMITER);
for(int i = 0; i < this.content.length; i++) {
if(this.content[i] instanceof RtfBasicElement) {
RtfBasicElement rbe = (RtfBasicElement)this.content[i];
rbe.writeContent(result);
}
}
result.write(CLOSE_GROUP);
}
Writes the content of this RtfHeaderFooter |