import java.awt.Color; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; import com.lowagie.text *;. import com.lowagie.text .rtf. *; / * *. 2004-11-10 * * Todo to change the template for this generated file go to * window - preferences - java - code style - code templates * / / / ** * @Author administrator * * TODO to change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates * / public class rTFCreate {public static void main (String [] args) throws MalformedURLException, IOException {rTFCreate rtfCreate = new RTFCreate (); try {rtfCreate.createRTF ();} catch (FileNotFoundException e) {// TODO Auto-generated catch block e.printStackTrace ();} catch (DocumentException e) {// TODO Auto-generated catch block e. PRINTSTACKTRACE ();}} public void creatertf () THROWS DocumentException, BadelementException, MalforMedurLexception, IOEXC eption {Document document = new Document (PageSize.A4); //document.addTitle("Title "); //document.addHeader("header","Header"); RtfWriter.getInstance (document, new FileOutputStream ( "C : /World.rtf "); Document.Open (); // Add a word document.add (new paragraph (" Hello World! Hello! HEHE! ")); // add a table table table = new table (3); table.setBorderwidth (1); table.setBorderColor (New Color (0, 0, 255)); table.setpadding (5); TABLE .SetSpacing (5); cell cell = new cell ("header"); cell.setheader (TRUE); cell.SetColspan (3); table.addcell (Cell); Table.ndHeaders (); cell = new cell (" EXAMPLE CELL with COLSPAN 1 and ROWSPAN 2 "); Cell.setrowsPan (2);
Cell.SetBorderColor (New Color (255, 0, 0)); Table.Addcell (Cell); Table.Addcell ("1.1"); Table.Addcell ("2.1"); Table.Addcell ("1.2"); table .addcell ("2.2"); table.addcell ("cell test1"); cell = new cell ("big cell"); cell.setrowspan (2); cell.SetColspan (2); Table.Addcell (Cell); Table.addcell ("cell test2"); document.add (Table); Image PNG = Image.GetInstance ("WorkswithMysql.png"); document.add (png); document.close ();}} Author Blog:
http://blog.9cbs.net/legenDinfo/