use of com.lowagie.text.rtf.RtfWriter2 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();
}
use of com.lowagie.text.rtf.RtfWriter2 in project itext2 by albfernandez.
the class DocumentSettingsTest method main.
/**
* Document settings example.
*/
@Test
public void main() throws Exception {
Document document = new Document();
// Keep a reference to the RtfWriter2 instance.
RtfWriter2 writer2 = RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("DocumentSettings.rtf"));
// Specify that the document caching is to be done on disk.
writer2.getDocumentSettings().setDataCacheStyle(RtfDataCache.CACHE_DISK);
// Specify that all \n are translated into soft linebreaks.
writer2.getDocumentSettings().setAlwaysGenerateSoftLinebreaks(true);
document.open();
document.add(new Paragraph("This example has been cached on disk\nand all " + "\\n have been translated into soft linebreaks."));
document.close();
}
Aggregations