itext生成pdf间距_使用itext生成pdf的,各种布局

1 packagecom.itext.test;2

3 importjava.io.FileOutputStream;4

5 importcom.itextpdf.text.BaseColor;6 importcom.itextpdf.text.Document;7 importcom.itextpdf.text.Element;8 importcom.itextpdf.text.Image;9 importcom.itextpdf.text.PageSize;10 importcom.itextpdf.text.Paragraph;11 importcom.itextpdf.text.pdf.BaseFont;12 importcom.itextpdf.text.pdf.PdfPCell;13 importcom.itextpdf.text.pdf.PdfPTable;14 importcom.itextpdf.text.pdf.PdfWriter;15

16

17 public classBaoXiaoDan {18 public static voidmain(String[] args) {19

20 try

21 {22 Document document = newDocument(PageSize.A4.rotate());23 PdfWriter.getInstance(document, new FileOutputStream("D:\\Helloworld.PDF"));24

25 //设置字体

26 BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);27 com.itextpdf.text.Font FontChinese24 = new com.itextpdf.text.Font(bfChinese, 24, com.itextpdf.text.Font.BOLD);28 com.itextpdf.text.Font FontChinese18 = new com.itextpdf.text.Font(bfChinese, 18, com.itextpdf.text.Font.BOLD);29 com.itextpdf.text.Font FontChinese16 = new com.itextpdf.text.Font(bfChinese, 16, com.itextpdf.text.Font.BOLD);30 com.itextpdf.text.Font FontChinese12 = new com.itextpdf.text.Font(bfChinese, 12, com.itextpdf.text.Font.NORMAL);31 com.itextpdf.text.Font FontChinese11Bold = new com.itextpdf.text.Font(bfChinese, 11, com.itextpdf.text.Font.BOLD);32 com.itextpdf.text.Font FontChinese11 = new com.itextpdf.text.Font(bfChinese, 11, com.itextpdf.text.Font.ITALIC);33 com.itextpdf.text.Font FontChinese11Normal = new com.itextpdf.text.Font(bfChinese, 11, com.itextpdf.text.Font.NORMAL);34

35 document.open();36 //table1

37 PdfPTable table1 = new PdfPTable(3);38 PdfPCell cell11 = new PdfPCell(new Paragraph("费用报销",FontChinese24));39 cell11.setVerticalAlignment(Element.ALIGN_MIDDLE);40 cell11.setHorizontalAlignment(Element.ALIGN_CENTER);41 cell11.setBorder(0);42 String imagePath = "D:/alibaba.jpg";43 Image image1 =Image.getInstance(imagePath);44

45 Image image2 =Image.getInstance(imagePath);46 //设置每列宽度比例

47 i

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值