use of com.lowagie.text.rtf.field.RtfTOCEntry in project itext2 by albfernandez.
the class RtfTOCandCellbordersTest method main.
/**
* Creates an RTF document with a TOC and Table with special Cellborders.
*/
@Test
public void main() throws Exception {
Document document = new Document();
RtfWriter2 writer2 = RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("toc.rtf"));
writer2.setAutogenerateTOCEntries(true);
document.open();
Paragraph para = new Paragraph();
para.add(new RtfTableOfContents("RIGHT CLICK AND HERE AND SELECT \"UPDATE FIELD\" TO UPDATE."));
document.add(para);
Paragraph par = new Paragraph("This is some sample content.");
Chapter chap1 = new Chapter("Chapter 1", 1);
chap1.add(par);
Chapter chap2 = new Chapter("Chapter 2", 2);
chap2.add(par);
document.add(chap1);
document.add(chap2);
for (int i = 0; i < 300; i++) {
if (i == 158) {
document.add(new RtfTOCEntry("This is line 158."));
}
document.add(new Paragraph("Line " + i));
}
document.add(new RtfTOCEntry("Cell border demonstration"));
Table table = new Table(3);
RtfCell cellDotted = new RtfCell("Dotted border");
cellDotted.setBorders(new RtfBorderGroup(Rectangle.BOX, RtfBorder.BORDER_DOTTED, 1, new Color(0, 0, 0)));
RtfCell cellEmbossed = new RtfCell("Embossed border");
cellEmbossed.setBorders(new RtfBorderGroup(Rectangle.BOX, RtfBorder.BORDER_EMBOSS, 1, new Color(0, 0, 0)));
RtfCell cellNoBorder = new RtfCell("No border");
cellNoBorder.setBorders(new RtfBorderGroup());
table.addCell(cellDotted);
table.addCell(cellEmbossed);
table.addCell(cellNoBorder);
document.add(table);
document.close();
}
Aggregations