① java項目中,使用openoffice4.1.1將ppt轉換成pdf報錯,如圖所示
先用
openoffice
直接轉換為pdf(打開openoffice,在openoffice文件菜單中打開該文檔,再在文件菜單中導出為pdf)
看看是不是openoffice本身對該文檔的支持不完善。
② Java如何為pdf文件添加書簽
為pdf文件添加書簽的方法有很多,下面給你介紹一種:
啟動Adobe Reader,隨便打開一個PDF文件,單擊菜單「編輯/首選項」,打開相應的對話框。 在左側單擊「Java script 」項,在右側勾選 「啟用Acrobat Java script (J)」、 「啟用菜單項目Java script 執行許可權(M)」 「啟用全局對象安全性策略」 單擊「確定」按鈕
此時,單擊菜單「視圖」,在出現的級聯菜單中。 你會發現多了「Bookmark This Page」 「Go To Bookmark」等四個與書簽有關的命令。 以後如果遇到需要插入書簽的時候,只需在文檔中選中相應的部分,單擊「Bookmark This Page」命令,然後在出現的「Bookmark Name」 (書簽名)對話框中,輸入書簽名稱,單擊「確定」按鈕,即可完成書簽的添加工作。
以後要快速定位到書簽時,只需在「視圖」菜單中選擇「Go To Bookmark」命令,然後從彈出的對話框中選擇相應的書簽名稱。 Adobe Reader就會自動轉到對應的部分,供你閱讀或標注了。
刪除書簽。如果僅僅想刪除某一個或幾個書簽,可以在「視圖」菜單下選擇「Remove a Bookmark」(刪除書簽)命令,並在出現的對話框中選擇不想繼續使用的書簽即可。 如果要一次性地刪除所有書簽,可在「視圖」菜單下選擇「Clear Bookmark」(清理書簽)命令。
③ java怎麼輸出pdf格式的文件
java導出pdf需要用到iText庫,iText是著名的開放源碼的站點sourceforge一個項目,是用於生成PDF文檔的一個java類庫。通過iText不僅可以生成PDF或rtf
的文檔,而且可以將XML、Html文件轉化為PDF文件。
iText的安裝非常方便,下載iText.jar文件後,只需要在系統的CLASSPATH中加入iText.jar的路徑,在程序中就可以使用
iText類庫了。
代碼如下:
public class createPdf {
//自己做的一個簡單例子,中間有圖片之類的
//先建立Document對象:相對應的 這個版本的jar引入的是com.lowagie.text.Document
Document document = new Document(PageSize.A4, 36.0F, 36.0F, 36.0F, 36.0F);
public void getPDFdemo() throws DocumentException, IOException{
//這個導出用的是 iTextAsian.jar 和iText-2.1.3.jar 屬於比較老的方法。 具體下在地址見:
//首先
//字體的定義:這里用的是自帶的jar裡面的字體
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);
// 當然你也可以用你電腦裡面帶的字體庫
//BaseFont bfChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMSUN.TTC,1",BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
//定義字體 注意在最新的包裡面 顏色是封裝的
Font fontChinese8 = new Font(bfChinese, 10.0F, 0, new Color(59, 54, 54));
//生成pdf的第一個步驟:
//保存本地指定路徑
saveLocal();
document.open();
ByteArrayOutputStream ba = new ByteArrayOutputStream();
// PdfWriter writer = PdfWriter.getInstance(document, ba);
document.open();
//獲取此編譯的文件路徑
String path = this.getClass().getClassLoader().getResource("").getPath();
//獲取根路徑
String filePath = path.substring(1, path.length()-15);
//獲取圖片路徑 找到你需要往pdf上生成的圖片
//這里根據自己的獲取的路徑寫 只要找到圖片位置就可以
String picPath = filePath +"\\WebContent" +"\\images\\";
//往PDF中添加段落
Paragraph pHeader = new Paragraph();
pHeader.add(new Paragraph(" 你要生成文字寫這里", new Font(bfChinese, 8.0F, 1)));
//pHeader.add(new Paragraph("文字", 字體 可以自己寫 也可以用fontChinese8 之前定義好的 );
document.add(pHeader);//在文檔中加入你寫的內容
//獲取圖片
Image img2 = Image.getInstance(picPath +"ccf-stamp-new.png");
//定義圖片在文檔中顯示的絕對位置
img2.scaleAbsolute(137.0F, 140.0F);
img2.setAbsolutePosition(330.0F, 37.0F);
//將圖片添加到文檔中
document.add(img2);
//關閉文檔
document.close();
/*//設置文檔保存的文件名
response.setHeader("Content-
disposition", "attachment;filename=\""+ new String(("CCF會員資格確認
函.pdf").getBytes("GBK"),"ISO-8859-1") + "\"");
//設置類型
response.setContentType("application/pdf");
response.setContentLength(ba.size());
ServletOutputStream out = response.getOutputStream();
ba.writeTo(out);
out.flush();*/
}
public static void main(String[]args) throws DocumentException, IOException{
createPdf pdf= new createPdf();
pdf.getPDFdemo();
}
//指定一個文件進行保存 這里吧文件保存到D盤的text.pdf
public void saveLocal() throws IOException, DocumentException{
//直接生成PDF 制定生成到D盤test.pdf
File file = new File("D:\\text2.pdf");
file.createNewFile();
PdfWriter.getInstance(document, new FileOutputStream(file));
}
}
④ Java如何使用Java創建一個空的PDF文檔
package com.yii;import java.io.IOException;import org.apache.pdfbox.pdmodel.PDDocument;import org.apache.pdfbox.pdmodel.PDPage;// 需要下 apache pdfbox包和apache.commons.loggin烏,下載地址:http://pdfbox.apache.org/download.cgi 和 http://commons.apache.org/proper/commons-logging/download_logging.cgi// 在本示例中下載使用的是:pdfbox-2.0.7.jar // 將下載的pdfbox-2.0.7.jar添加到Eclipse項目依懶庫中。// 右鍵點擊:"java_apache_pdf_box"->"Bulid Path"->"Add External Artchives...",然後選篤下載的"pdfbox-2.0.7.jar"和"commons-logging-1.2.jar"文件 public class CreatingEmptyPdf {
public static void main(String args[]) throws IOException {
// Creating PDF document object
PDDocument document = new PDDocument();
// Add an empty page to it
document.addPage(new PDPage());
// Saving the document
document.save("F:/worksp/javaexamples/java_apache_pdf_box/BlankPdf.pdf");
System.out.println("PDF created");
// Closing the document
document.close();
}}
⑤ 如何運用Java組件itext生成pdf
首先從iText的官網下載這個開源的小組件。
iText官方網站
Java版iText組件
Java版工具包
C#版iText組件
C#版工具包
這里筆者使用的是Java版itext-5.2.1。
將itext-5.2.1.zip壓縮包解壓縮後得到7個文件:itextpdf-5.2.1.jar(核心組件)、itextpdf-5.2.1-javadoc.jar(API文檔)、itextpdf-5.2.1-sources.jar(源代碼)、itext-xtra-5.2.1.jar、itext-xtra-5.2.1-javadoc.jar、itext-xtra-5.2.1-sources.jar
使用5步即可生成一個簡單的PDF文檔。
復制代碼
1 // 1.創建 Document 對象
2 Document _document = new Document();
3 // 2.創建書寫器,通過書寫器將文檔寫入磁碟
4 PdfWriter _pdfWriter = PdfWriter.getInstance(_document, new FileOutputStream("生成文件的路徑"));
5 // 3.打開文檔
6 _document.open();
7 // 4.向文檔中添加內容
8 _document.add(new Paragraph("Hi"));
9 // 5.關閉文檔
10 _document.close();
復制代碼
OK,搞定,不出問題的話就會在你指定的路徑中生成一個PDF文檔,內容是純文本的「Hi」。
可是這樣並不能完全滿足我們的需求,因為通常我們要生成的PDF文件不一定是純文本格式的,比如我現在要實現列印銷售單的功能,那麼最起碼需要繪製表格才行,怎麼辦呢?且跟筆者繼續向下研究。
在iText中,有專門的表格類,即PdfPTable類。筆者做了一個簡單的表格示例,請先看代碼:
復制代碼
1 OutTradeList _otl = this.getOtlBiz().findOutTradeListById(this.getOtlid());
2 String _fileName = _otl.getOtlId() + ".pdf";
3
4 // iText 處理中文
5 BaseFont _baseFont = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", true);
6 // 1.創建 Document 對象
7 Document _document = new Document(PageSize.A4);
8
9 HttpServletResponse response = ServletActionContext.getResponse();
10 response.setContentType("application/pdf; charset=ISO-8859-1");
11 response.setHeader("Content-Disposition", "inline; filename=" + new String(_fileName.getBytes(), "iso8859-1"));
12
13 // 2.創建書寫器,通過書寫器將文檔寫入磁碟
14 PdfWriter _pdfWriter = null;
15 try {
16 _pdfWriter = PdfWriter.getInstance(_document, response.getOutputStream());
17 } catch (Exception e) {
18 this.setMessage("單據生成失敗,請檢查伺服器目錄許可權配置是否正確");
19 e.printStackTrace();
20 System.out.println("2.掛了");
21 // return INPUT;
22 return null;
23 }
24 if(_pdfWriter == null) {
25 this.setMessage("單據生成失敗,請檢查伺服器目錄許可權配置是否正確");
26 System.out.println("3.掛了");
27 // return INPUT;
28 return null;
29 }
30
31 // 3.打開文檔
32 _document.open();
33
34 // 4.創建需要填入文檔的元素
35 PdfPTable _table = new PdfPTable(4);
36 PdfPCell _cell = null;
37
38 _table.addCell(new Paragraph("單據號", new Font(_baseFont)));
39 _cell = new PdfPCell(new Paragraph(_otl.getOtlId()));
40 _cell.setColspan(3);
41 _table.addCell(_cell);
42
43 _table.addCell(new Paragraph("客戶名稱", new Font(_baseFont)));
44 _cell = new PdfPCell(new Paragraph(_otl.getClients().getName(), new Font(_baseFont)));
45 _cell.setColspan(3);
46 _table.addCell(_cell);
47
48 _table.addCell(new Paragraph("銷售日期", new Font(_baseFont)));
49 _cell = new PdfPCell(new Paragraph(_otl.getOutDate().toString()));
50 _cell.setColspan(3);
51 _table.addCell(_cell);
52
53 _cell = new PdfPCell();
54 _cell.setColspan(4);
55 PdfPTable _tabGoods = new PdfPTable(7);
56 // 添加標題行
57 _tabGoods.setHeaderRows(1);
58 _tabGoods.addCell(new Paragraph("序號", new Font(_baseFont)));
59 _tabGoods.addCell(new Paragraph("商品名稱", new Font(_baseFont)));
60 _tabGoods.addCell(new Paragraph("自定義碼", new Font(_baseFont)));
61 _tabGoods.addCell(new Paragraph("規格", new Font(_baseFont)));
62 _tabGoods.addCell(new Paragraph("數量", new Font(_baseFont)));
63 _tabGoods.addCell(new Paragraph("單價", new Font(_baseFont)));
64 _tabGoods.addCell(new Paragraph("小計", new Font(_baseFont)));
65 Object[] _outTrades = _otl.getOutTrades().toArray();
66 // 將商品銷售詳細信息加入表格
67 for(int i = 0; i < _outTrades.length;) {
68 if((_outTrades[i] != null) && (_outTrades[i] instanceof OutTrade)) {
69 OutTrade _ot = (OutTrade) _outTrades[i];
70 Goods _goods = _ot.getGoods();
71 _tabGoods.addCell(String.valueOf((++i)));
72 _tabGoods.addCell(new Paragraph(_goods.getName(), new Font(_baseFont)));
73 _tabGoods.addCell(_goods.getUserCode());
74 _tabGoods.addCell(_goods.getEtalon());
75 _tabGoods.addCell(String.valueOf(_ot.getNum()));
76 _tabGoods.addCell(String.valueOf(_ot.getPrice()));
77 _tabGoods.addCell(String.valueOf((_ot.getNum() * _ot.getPrice())));
78 }
79 }
80 _cell.addElement(_tabGoods);
81 _table.addCell(_cell);
82
83 _table.addCell(new Paragraph("總計", new Font(_baseFont)));
84 _cell = new PdfPCell(new Paragraph(_otl.getAllPrice().toString()));
85 _cell.setColspan(3);
86 _table.addCell(_cell);
87
88 _table.addCell(new Paragraph("操作員", new Font(_baseFont)));
89 _cell = new PdfPCell(new Paragraph(_otl.getProcure()));
90 _cell.setColspan(3);
91 _table.addCell(_cell);
92
93 // 5.向文檔中添加內容,將表格加入文檔中
94 _document.add(_table);
95
96 // 6.關閉文檔
97 _document.close();
98 System.out.println(_fileName);
99 this.setPdfFilePath(_fileName);
100 System.out.println("3.搞定");
101 // return SUCCESS;
102 return null;
復制代碼
以上代碼是寫在 Struts2 的 Action 中的,當用戶發送了請求之後直接將生成的PDF文件用輸出流寫入到客戶端,瀏覽器收到伺服器的響應之後就會詢問用戶打開方式。
當然,我們也可以將文件寫入磁碟等等。
⑥ 怎麼用java代碼生成pdf文檔
package com.qhdstar.java.pdf;
import java.awt.Color;
import java.io.FileOutputStream;
import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.pdf.PdfWriter;
/**
* 描述:TODO 【JAVA生成PDF】
* <p>
*
* @title GeneratePDF
* @author SYJ
* @email [email protected]
* @date 2013-4-6
* @version V1.0
*/
public class GeneratePDF {
public static void main(String[] args) {
//調用第一個方法,向C盤生成一個名字為ITextTest.pdf 的文件
try {
writeSimplePdf();
}
catch (Exception e) { e.printStackTrace(); }
//調用第二個方法,向C盤名字為ITextTest.pdf的文件,添加章節。
try {
writeCharpter();
}
catch (Exception e) { e.printStackTrace(); }
}
public static void writeSimplePdf() throws Exception {
// 1.新建document對象
// 第一個參數是頁面大小。接下來的參數分別是左、右、上和下頁邊距。
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
// 2.建立一個書寫器(Writer)與document對象關聯,通過書寫器(Writer)可以將文檔寫入到磁碟中。
// 創建 PdfWriter 對象 第一個參數是對文檔對象的引用,第二個參數是文件的實際名稱,在該名稱中還會給出其輸出路徑。
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\ITextTest.pdf"));
// 3.打開文檔
document.open();
// 4.向文檔中添加內容
// 通過 com.lowagie.text.Paragraph 來添加文本。可以用文本及其默認的字體、顏色、大小等等設置來創建一個默認段落
document.add(new Paragraph("First page of the document."));
document.add(new
Paragraph("Some more text on the first page with different color and
font type.", FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new
Color(255, 150, 200))));
// 5.關閉文檔
document.close();
}
/**
* 添加含有章節的pdf文件
*
* @throws Exception
*/
public static void writeCharpter() throws Exception {
// 新建document對象 第一個參數是頁面大小。接下來的參數分別是左、右、上和下頁邊距。
Document document = new Document(PageSize.A4, 20, 20, 20, 20);
// 建立一個書寫器(Writer)與document對象關聯,通過書寫器(Writer)可以將文檔寫入到磁碟中。
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:\\ITextTest.pdf"));
// 打開文件
document.open();
// 標題
document.addTitle("Hello mingri example");
// 作者
document.addAuthor("wolf");
// 主題
document.addSubject("This example explains how to add metadata.");
document.addKeywords("iText, Hello mingri");
document.addCreator("My program using iText");
// document.newPage();
// 向文檔中添加內容
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));
document.add(new Paragraph("First page of the document."));
document.add(new Paragraph("First page of the document."));
document.add(new Paragraph("First page of the document."));
document.add(new Paragraph("First page of the document."));
document.add(new
Paragraph("Some more text on the first page with different color and
font type.", FontFactory.getFont(FontFactory.defaultEncoding, 10,
Font.BOLD, new Color(0, 0, 0))));
Paragraph title1 = new
Paragraph("Chapter 1", FontFactory.getFont(FontFactory.HELVETICA, 18,
Font.BOLDITALIC, new Color(0, 0, 255)));
// 新建章節
Chapter chapter1 = new Chapter(title1, 1);
chapter1.setNumberDepth(0);
Paragraph
title11 = new Paragraph("This is Section 1 in Chapter 1",
FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, new Color(255,
0, 0)));
Section section1 = chapter1.addSection(title11);
Paragraph someSectionText = new Paragraph("This text comes as part of section 1 of chapter 1.");
section1.add(someSectionText);
someSectionText = new Paragraph("Following is a 3 X 2 table.");
section1.add(someSectionText);
document.add(chapter1);
// 關閉文檔
document.close();
}
}
⑦ java導出PDF文檔
java導出pdf需要用到iText庫,iText是著名的開放源碼的站點sourceforge一個項目,是用於生成PDF文檔的一個java類庫。通過iText不僅可以生成PDF或rtf
的文檔,而且可以將XML、Html文件轉化為PDF文件。
iText的安裝非常方便,下載iText.jar文件後,只需要在系統的CLASSPATH中加入iText.jar的路徑,在程序中就可以使用
iText類庫了。
代碼如下:
public class createPdf {
//自己做的一個簡單例子,中間有圖片之類的
//先建立Document對象:相對應的 這個版本的jar引入的是com.lowagie.text.Document
Document document = new Document(PageSize.A4, 36.0F, 36.0F, 36.0F, 36.0F);
public void getPDFdemo() throws DocumentException, IOException{
//這個導出用的是 iTextAsian.jar 和iText-2.1.3.jar 屬於比較老的方法。 具體下在地址見:
//首先
//字體的定義:這里用的是自帶的jar裡面的字體
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", false);
// 當然你也可以用你電腦裡面帶的字體庫
//BaseFont bfChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMSUN.TTC,1",BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
//定義字體 注意在最新的包裡面 顏色是封裝的
Font fontChinese8 = new Font(bfChinese, 10.0F, 0, new Color(59, 54, 54));
//生成pdf的第一個步驟:
//保存本地指定路徑
saveLocal();
document.open();
ByteArrayOutputStream ba = new ByteArrayOutputStream();
// PdfWriter writer = PdfWriter.getInstance(document, ba);
document.open();
//獲取此編譯的文件路徑
String path = this.getClass().getClassLoader().getResource("").getPath();
//獲取根路徑
String filePath = path.substring(1, path.length()-15);
//獲取圖片路徑 找到你需要往pdf上生成的圖片
//這里根據自己的獲取的路徑寫 只要找到圖片位置就可以
String picPath = filePath +"\\WebContent" +"\\images\\";
//往PDF中添加段落
Paragraph pHeader = new Paragraph();
pHeader.add(new Paragraph(" 你要生成文字寫這里", new Font(bfChinese, 8.0F, 1)));
//pHeader.add(new Paragraph("文字", 字體 可以自己寫 也可以用fontChinese8 之前定義好的 );
document.add(pHeader);//在文檔中加入你寫的內容
//獲取圖片
Image img2 = Image.getInstance(picPath +"ccf-stamp-new.png");
//定義圖片在文檔中顯示的絕對位置
img2.scaleAbsolute(137.0F, 140.0F);
img2.setAbsolutePosition(330.0F, 37.0F);
//將圖片添加到文檔中
document.add(img2);
//關閉文檔
document.close();
/*//設置文檔保存的文件名
response.setHeader("Content-
disposition", "attachment;filename=\""+ new String(("CCF會員資格確認
函.pdf").getBytes("GBK"),"ISO-8859-1") + "\"");
//設置類型
response.setContentType("application/pdf");
response.setContentLength(ba.size());
ServletOutputStream out = response.getOutputStream();
ba.writeTo(out);
out.flush();*/
}
public static void main(String[]args) throws DocumentException, IOException{
createPdf pdf= new createPdf();
pdf.getPDFdemo();
}
//指定一個文件進行保存 這里吧文件保存到D盤的text.pdf
public void saveLocal() throws IOException, DocumentException{
//直接生成PDF 制定生成到D盤test.pdf
File file = new File("D:\\text2.pdf");
file.createNewFile();
PdfWriter.getInstance(document, new FileOutputStream(file));
}
}
⑧ java創建pdf文件寫入不進去
可以用生成PDF報表的Java組件--iText。
具體實現方法如下:1、導入itext-2。1。5。jar跟itextasian-1。5。2。jar兩個包到項目里,2、建立一個pdf文件。
一般情況下,iText使用在有以下一個要求的項目中:1。內容無法提前利用:取決於用戶的輸入或實時的資料庫信息。2。由於內容,頁面過多,PDF文檔不能手動生成。3。文檔需在無人參與,批處理模式下自動創建。4。內容被定製或個性化。
⑨ java中怎麼利用poi和itext生成pdf文檔
生成PDF文檔代碼如下:
packagepoi.itext;
importjava.io.FileOutputStream;
importjava.io.IOException;
importjava.awt.Color;
importcom.lowagie.text.*;
importcom.lowagie.text.pdf.*;
importcom.lowagie.text.pdf.BaseFont;
/**
*創建Pdf文檔
*@authorAdministrator
*
*/
publicclassHelloPdf
{
publicstaticvoidmain(String[]args)throwsException
{
BaseFontbfChinese=BaseFont.createFont("STSong-Light","UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);
FontFontChinese=newFont(bfChinese,12,Font.NORMAL);
//第一步,創建document對象
RectanglerectPageSize=newRectangle(PageSize.A4);
//下面代碼設置頁面橫置
//rectPageSize=rectPageSize.rotate();
//創建document對象並指定邊距
Documentdoc=newDocument(rectPageSize,50,50,50,50);
Documentdocument=newDocument();
try
{
//第二步,將Document實例和文件輸出流用PdfWriter類綁定在一起
//從而完成向Document寫,即寫入PDF文檔
PdfWriter.getInstance(document,newFileOutputStream("src/poi/itext/HelloWorld.pdf"));
//第3步,打開文檔
document.open();
//第3步,向文檔添加文字.文檔由段組成
document.add(newParagraph("HelloWorld"));
Paragraphpar=newParagraph("世界你好",FontChinese);
document.add(par);
PdfPTabletable=newPdfPTable(3);
for(inti=0;i<12;i++)
{
if(i==0)
{
PdfPCellcell=newPdfPCell();
cell.setColspan(3);
cell.setBackgroundColor(newColor(180,180,180));
cell.addElement(newParagraph("表格頭",FontChinese));
table.addCell(cell);
}
else
{
PdfPCellcell=newPdfPCell();
cell.addElement(newParagraph("表格內容",FontChinese));
table.addCell(cell);
}
}
document.add(table);
}
catch(DocumentExceptionde)
{
System.err.println(de.getMessage());
}
catch(IOExceptionioe)
{
System.err.println(ioe.getMessage());
}
//關閉document
document.close();
System.out.println("生成HelloPdf成功!");
}
}
希望對你有幫助。
⑩ 用webservice接收pdf文件的二進制字元串,在java項目中如何把二進制字元串轉換成pdf
JasperReports, 你可以上網查一下這個技術。我們現在做的項目就是應用這個技術的。用iReport生成一個.jasper模板文件,然後用java代碼讀取這個文件並向其中set值(讀取jasper文件的方法你應該知道吧,就是利用java的io,比如用File:File reportFile = new File(reportFilePath);),然後再用jasperreporst封裝好的方法(比如JasperExportManager.exportReportToPdfStream這個方法,當然,你需要先導入對應的jar包)生成最終生成的pdf文件中就含有java代碼set進去的值了。由於正在做的項目包含這個技術,所以就給你講講,不明白的地方可以一起討論。