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.html.htmlwriter;
/*
* created on 2004-11-10
*
*/
/**
* @author liao chuan(liao_chuan@shhicom.com.cn)
*
*/
public class htmlcreate {
public static void main(string[] args) throws malformedurlexception, ioexception {
htmlcreate htmlcreate = new htmlcreate();
try {
htmlcreate.createhtml();
} catch (filenotfoundexception e) {
// todo auto-generated catch block
e.printstacktrace();
} catch (documentexception e) {
// todo auto-generated catch block
e.printstacktrace();
}
}
public void createhtml() throws documentexception, badelementexception, malformedurlexception, ioexception
{
document document = new document(pagesize.a4);
//document.addtitle("title");
//document.addheader("header","header");
htmlwriter.getinstance(document, new fileoutputstream("c:/world.html"));
document.open();
//add a word
document.add(new paragraph("hello world!您好!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.endheaders();
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();
}
}
闽公网安备 35060202000074号