网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.Java虚拟机(JVM)对象创建浅析.
.Java语言深入 JAVA之精髓IO流.
.21种代码的“坏味道”.
.使用Decorator模式实现日期选择组.
.java类加载的表现形式.
.用java读写ini配置文件.
.利用HSQLDB进行Hibernate的单元测.
.SUN力推Java数据对象标准展示倡导.
.Java嵌入式开发之j2me--二.
.如何在Java程序中实现FTP的上传下.
.Java基础入门 初学Java编程的一些.
.Java设计模式之修饰模式篇(1).
.tomcat配置web在线后台管理.
.如何编写一个JAVA的队列类?.
.EJB设计模式3.
.int、char、double与byte如何相互.
.Size 属性.
.JDK5 新特性之新的格式化输出.
.使用XML小服务程序配置文件配置小.
.中文内容Properties文件的编辑.

use itext to create a html

发表日期:2008-1-5


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");

上一篇:javamail 处理html信件的方法,包括发送html和接受html邮件 人气:926
下一篇:调试工具系列--java 正则表达式(regular expression)调试工具 人气:1361
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐