Import java. Io. fileoutputstream;
Import java. Io. ioexception;
Import com. lowagie. Text. Document;
Import com. lowagie. Text. extends entexception;
Import com. lowagie. Text. Font;
Import com. lowagie. Text. headerfooter;
Import com. lowagie. Text. pagesize;
Import com. lowagie. Text. Paragraph;
Import com. lowagie. Text. phrase;
Import com. lowagie. Text. rectangle;
Import com.lowagie.text=. basefont;
Import com. lowagie. Text. rtf. rtfwriter2;
Public class rules {
Public static void main (string [] ARGs) throws disable entexception, ioexception {
Document document = new document (pagesize. A4 );
Rtfwriter2.getinstance (document, new fileoutputstream ("E:/1.doc "));
Document. open ();
// Add a header
Headerfooter header = new headerfooter (new phrase ("Header"), false );
Header. setalignment (rectangle. align_center );
Document. setheader (header );
// Add a footer
Headerfooter footer = new headerfooter (new phrase ("footer"), false );
Footer. setalignment (rectangle. align_center );
Document. setfooter (footer );
// Set the Chinese font
Basefont bfchinese = basefont. createfont ("stsongstd-light", "UniGB-UCS2-H", basefont. not_embedded );
Font contextfont = new font (bfchinese, 10, Font. Normal );
Paragraph context = new paragraph ("");
Context. setfont (contextfont );
// Image PNG = image. getinstance ("D:/busy.gif ");
// PNG. setabsoluteposition (0, 0 );
// PNG. setalignment (image. textwrap );
Context. Add ("content 1 ");
// Context. Add (new phrase (New chunk (PNG, 0, 0, true )));
Context. Add ("content 2 ");
// Context. Add (new phrase (New chunk (PNG, 0, 0, true )));
Context. Add ("content 3 ");
Document. Add (context );
Document. Close ();
}
}
Original post address: http://housen1987.iteye.com/blog/1335036