网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
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中轻松打印文档.
.关注性能:改进您的开发过程.
.编写 Servlet 2.3 Filter (一).
.J2ME开发手机游戏物理模型之抛物.
.查询分页与CheckBox全选提交.
.JNI完全手册(一).
.关于Hibernate开发框架中的各个包.
.做一个带有beans的文字计数器.
.如何开发会话Bean(无状态会话Be.
.使用低级UI制作图解应用程序.
.在java应用程序中显示数据库的bl.
.WebWork的强大的验证器.
.Java中的两个特殊变量this和super.
.Java名词解释.
.J2EE体系结构.
.JAVA上加密算法的实现用例(2).
.抽象类和接口-实战练习.
.从XML到Java的数据绑定之三.
.使用BINCompiler转换游戏资源文件.
.用JAVA开发CORBA应用实例.

use itext create a PDF file

发表日期: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.pdf.*;
/*
 * Created on 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 PDFCreate {

 public static void main(String[] args) throws MalformedURLException, IOException {
  PDFCreate pdfCreate = new PDFCreate();
  try {
   pdfCreate.createPDF();
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (DocumentException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
 public void createPDF() throws DocumentException, BadElementException, MalformedURLException, IOException
 {
  Document document = new Document(PageSize.A4);
  //document.addTitle("Title");
  //document.addHeader("header","Header");
  
  PdfWriter.getInstance(document, new FileOutputStream("C:/Helloworld.PDF"));
  
  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);

上一篇:Java Unicode转义字符的小小研究 人气:1641
下一篇:user itext create a word file 人气:783
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐