国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - itext生成PDF設置頁眉頁腳的實例詳解

itext生成PDF設置頁眉頁腳的實例詳解

2021-01-09 14:22tujiyue Java教程

這篇文章主要介紹了itext生成PDF設置頁眉頁腳的實例詳解的相關資料,希望通過本文能幫助到大家,需要的朋友可以參考下

itext生成pdf設置頁眉頁腳的實例詳解

實例代碼:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
 * itexttest
 * itext生成pdf加入列表,注釋等內容,同時設置頁眉和頁腳及頁碼等。
 */
package com.labci.itext.test;
import java.awt.color;
import java.io.filenotfoundexception;
import java.io.fileoutputstream;
import java.io.ioexception;
import com.lowagie.text.annotation;
import com.lowagie.text.document;
import com.lowagie.text.documentexception;
import com.lowagie.text.font;
import com.lowagie.text.headerfooter;
import com.lowagie.text.list;
import com.lowagie.text.listitem;
import com.lowagie.text.phrase;
import com.lowagie.text.rectangle;
import com.lowagie.text.pdf.basefont;
import com.lowagie.text.pdf.pdfwriter;
/**
 * @author bill tu(tujiyue/iwtxokhtd)
 * jun 6, 2011[4:10:35 pm]
 *
 */
public class itextlist {
  private final static string result_file="itext_list.pdf";
   
  public static void main(string []args){
    document doc=new document();
     
    try {
       
       
       
      pdfwriter.getinstance(doc, new fileoutputstream(result_file));
      basefont fontchinese=null;
      try {
        fontchinese = basefont.createfont("stsong-light","unigb-ucs2-h",basefont.not_embedded);//設置中文字體
      } catch (ioexception e) {
        e.printstacktrace();
      }
     
      font chinese = new font(fontchinese, 10, font.normal); 
       
      /**
       * headerfooter的第2個參數為非false時代表打印頁碼
       * 頁眉頁腳中也可以加入圖片,并非只能是文字
       */
      headerfooter header=new headerfooter(new phrase("這僅僅是個頁眉,頁碼在頁腳處",chinese),false);
       
      //設置是否有邊框等
//     header.setborder(rectangle.no_border);
      header.setborder(rectangle.bottom);
      header.setalignment(1);
      header.setbordercolor(color.red);
      doc.setheader(header);
       
      headerfooter footer=new headerfooter(new phrase("-",chinese),new phrase("-",chinese));
      /**
       * 0是靠左
       * 1是居中
       * 2是居右
       */
      footer.setalignment(1);
      footer.setbordercolor(color.red);
      footer.setborder(rectangle.box);
      doc.setfooter(footer);
     
      /**
       * 頁眉頁腳的設置一定要在open前設置好
       */
      doc.open();
      /**
       * true:代表要排序,10代表序號與文字之間的間距
       * false:代表不排序,則文字前的符號為"-"
       */
      list itextlist=new list(true,10);
       
      /**
       * 也可以改變列表的符號[可選]
       *
$$$
       * 要改變列表符號時,上面的list構造方法第一參數值必須為false
       *
$$$
       * 可以使用字符串,chunk,image等作列表符號,如下
       */
      //itextlist.setlistsymbol("*");
       
      listitem firstitem=new listitem("first paragraph");
      listitem seconditem=new listitem("second paragraph");
      listitem thirditem=new listitem("third paragraph");
      itextlist.add(firstitem);
      itextlist.add(seconditem);
      itextlist.add(thirditem);
       
      doc.add(itextlist);
       
      //添加注釋,注釋有標題和內容,注釋可以是文本,內部鏈接,外部鏈接,圖片等
      annotation annotation=new annotation("what's this?","it's a tree and it is not a big");
       
      doc.add(annotation);
       
      doc.close();
    } catch (filenotfoundexception e) {
      e.printstacktrace();
    } catch (documentexception e) {
      e.printstacktrace();
    }
  }
}

工程結構圖:

itext生成PDF設置頁眉頁腳的實例詳解

itext生成PDF設置頁眉頁腳的實例詳解

itext生成PDF設置頁眉頁腳的實例詳解

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

原文鏈接:http://blog.csdn.net/tujiyue/article/details/6528372

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 成人国产精品久久 | 成人综合视频在线 | 久久久久久亚洲精品 | 欧美成人精品在线视频 | 欧美色影院 | 亚洲国产精品尤物yw在线观看 | 日韩色影| 免费又黄又爽又猛的毛片 | 91香蕉 | 亚洲国产精品99久久久久久久久 | 一区二区三区高清 | 九九九久久国产免费 | 国产精品久久久久国产a级 成人a在线视频 | 亚洲一二三 | 人人九九精 | 日韩综合网 | 国产小视频在线播放 | 成人av片在线观看 | 免费一二区 | 久久蜜桃精品一区二区三区综合网 | 欧美日韩亚洲视频 | 精品久久久久久久久久久久 | 亚洲精品国产综合99久久夜夜嗨 | 懂色av一区二区三区 | 免费观看污污视频 | 久久成人国产精品 | 亚洲一级黄色 | 国产激情一区二区三区成人免费 | 91亚洲精品在线 | 99这里只有精品 | 久久涩| 亚洲精品日韩激情在线电影 | 国产在线一区二区三区 | 欧美精品亚洲精品 | 成人av视屏| a级免费电影 | 99激情| 国产成人久久av免费高清密臂 | 激情五月综合 | 日本免费在线视频 | 日日精品 |