pdf生成功能

package com.fineway.hcs.file.util;
import java.io.*;

import java.text.SimpleDateFormat;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.*;

public class test {

public static void main(String[] args) throws IOException, DocumentException {

    // 模板路径  C:/hhywk/lib/success_temp.pdf
    String templatePath = "C:/hhywk/lib/success_temp.pdf";

// String templatePath = “D:/fail.pdf”;
// 生成的新文件路径
// String newPDFPath = “D:/success_temp.pdf”;
String targetPath = “C:/hhywk/lib/success.pdf”;

    // 读取模板文件

// InputStream input = new FileInputStream(new File(templatePath));
// PdfReader reader = new PdfReader(input);
// PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(targetPath));
// 提取pdf中的表单
// AcroFields form = stamper.getAcroFields();
// form.addSubstitutionFont(BaseFont.createFont(“STSong-Light”,“UniGB-UCS2-H”, BaseFont.NOT_EMBEDDED));
BaseFont bf = BaseFont.createFont(“C:\hhywk\lib\simsun.ttf”,
BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 12, Font.NORMAL);
// form.addSubstitutionFont(bf);
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(“C:/hhywk/lib/success.pdf”));
String text1 = "啊发生的发球特工是大哥是法国时的风格是This is the quite popular True Type "+new java.util.Date();
document.open();
document.add(new Paragraph(text1, font));
document.add(new Paragraph(text1, font));
document.close();
// stamper.close();
// reader.close();
}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值