Import java. Io. fileoutputstream;
Import java. Io. outputstream;
Import java. Io. stringreader;
Import java. util. List;
Import com. lowagie. Text. Document;
Import com. lowagie. Text. pagesize;
Import com. lowagie. Text. Paragraph;
Import com.lowagie.text.html. simpleparser. htmlworker;
Import com.lowagie.text.html. simpleparser. stylesheet;
Import com. lowagie. Text. rtf. rtfwriter2;
Public class itextcreatertf
{
Public static void main (string [] ARGs) throws exception
{< br> outputstream out = new fileoutputstream ("C: // a.doc");
document = new document (pagesize. a4);
rtfwriter2.getinstance (document, out);
document. open ();
paragraph context = new paragraph ();
string htmlcontent =" ";
stylesheet SS = new stylesheet ();
List htmllist = htmlworker. parsetolist (New stringreader ( htmlcontent ),
SS );
for (INT I =; I
{
Com. lowagie. Text. Element E = (COM. lowagie. Text. element) htmllist. Get (I );
Context. Add (E );
}
Document. Add (context );
Document. Close ();
System. Out. println ("OK ");
}
}
Htmlcontent is the HTML content that needs to be converted into Word documents. It can be an image or any other HTML content. It parses HTML tags into the format. The original post address contains more detailed operations on the image.
Original post address: http://af8991.iteye.com/blog/853107