資源簡介
1、生成PDF文件
2、支持中文字體
3、PDF文件內(nèi)容為表格,表格有表頭
4、PDF文件內(nèi)容支持中文,表格內(nèi)容上下居中,左右居中或左對齊/右對齊
5、PDF列信息多寡不同,PDF采用頁面寬度也能根據(jù)列信息按比例調(diào)整
6、PDF行信息超大時(shí)寫入模式,不能引起內(nèi)存溢出等問題,有一定的并發(fā)性支撐能力。
7、PDF文件增加作者相關(guān)版權(quán)信息
8、PDF頁頭增加版權(quán)相關(guān)信息
9、PDF文件修改權(quán)限限制,實(shí)現(xiàn)文檔只可讀取的權(quán)限
10、PDF文件增加文字或圖片水印功能,要求文字或圖片在整個(gè)頁面清晰可見。增加的水印信息不能使PDF文件大小增長超過5%。
11、對PDF文件進(jìn)行加密

代碼片段和文件信息
package?com.fruitking.testpdf.util;
import?java.io.File;
import?java.io.FileNotFoundException;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.OutputStream;
import?com.lowagie.text.Document;
import?com.lowagie.text.DocumentException;
import?com.lowagie.text.Font;
import?com.lowagie.text.Paragraph;
import?com.lowagie.text.pdf.baseFont;
import?com.lowagie.text.pdf.PdfWriter;
public?class?PDFCreate1File?{
/**
?*?創(chuàng)建一份PDF文檔
?*?@param?fullFilePath
?*/
public?boolean?createPDFFile(String?fullFilePath){
????????Document?pdfDocument?=?new?Document();
????????try?{
????????????//構(gòu)建一個(gè)PDF文檔輸出流程
???????? OutputStream?pdfFileOutputStream?=?new?FileOutputStream(new?File(fullFilePath));
???????? PdfWriter.getInstance(pdfDocumentpdfFileOutputStream);
???????? //設(shè)置中文字體和字體樣式
????????????baseFont?bfChinese?=?baseFont.createFont(“STSong-Light“?“UniGB-UCS2-H“?baseFont.NOT_embedDED);??
????????????Font?f2?=?new?Font(bfChinese?2?Font.NORMAL);
????????????Font?f6?=?new?Font(bfChinese?6?Font.NORMAL);
????????????Font?f10?=?new?Font(bfChinese?10?Font.NORMAL);
????????????Font?f12?=?new?Font(bfChinese?12?Font.BOLD);
????????????//打開PDF文件流
???????? pdfDocument.open();
????????????//設(shè)置PDF文件正文內(nèi)容
????????????pdfDocument.add(new?Paragraph(“中國程序員周報(bào)“?f12));?
????????????//換行
????????????pdfDocument.add(new?Paragraph(“?“f6));?
????????????//換行
????????????pdfDocument.add(new?Paragraph(“中國程序員工作時(shí)間調(diào)查報(bào)告“?f10));?
????????????//換行
????????????pdfDocument.add(new?Paragraph(“?“?f2));
????????????return?true;
????????}catch(FileNotFoundException?de)?{
????????????de.printStackTrace();
????????????System.err.println(“pdf?file:?“?+?de.getMessage());
????????????return?false;
????????}catch(DocumentException?de)?{
????????????de.printStackTrace();
????????????System.err.println(“document:?“?+?de.getMessage());
????????????return?false;
????????}catch(IOException?de)?{
????????????de.printStackTrace();
????????????System.err.println(“pdf?font:?“?+?de.getMessage());
????????????return?false;
????????}finally{
????????????//關(guān)閉PDF文檔流,OutputStream文件輸出流也將在PDF文檔流關(guān)閉方法內(nèi)部關(guān)閉
???????? if(pdfDocument!=null){
???????? pdfDocument.close();
???????? }
????????}????????
????}
/**
?*?創(chuàng)建一份PDF文檔,且標(biāo)注作者等信息
?*?@param?fullFilePath
?*/
public?boolean?createPDFFileWithCreatorInfo(String?fullFilePath){
????????Document?pdfDocument?=?new?Document();
????????try?{
????????????//構(gòu)建一個(gè)PDF文檔輸出流程
???????? OutputStream?pdfFileOutputStream?=?new?FileOutputStream(new?File(fullFilePath));
???????? PdfWriter?pdfWriter?=?PdfWriter.getInstance(pdfDocumentpdfFileOutputStream);
???????? //PDF版本(默認(rèn)1.4)
???????? pdfWriter.setPdfVersion(PdfWriter.PDF_VERSION_1_4);
????????????//文檔屬性
????????????pdfDocument.addtitle(“水果大王信息技術(shù)有限公司數(shù)據(jù)安全產(chǎn)品“);
????????????pdfDocument.addAuthor(“杭州水果大王信息技術(shù)有限公司“);
????????????pdfDocument.addSubject(“文件導(dǎo)出的信息安全管控“);
????????????pdfDocument.addKeywords(“文件導(dǎo)出信息安全“);//文檔關(guān)鍵字信
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-11-26?16:42??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\
?????目錄???????????0??2014-03-27?10:34??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\
?????文件?????1825962??2013-10-18?12:10??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\bcprov-ext-jdk15-1.46.jar
?????文件?????1130070??2014-03-27?09:38??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\itext-2.1.7.jar
?????文件?????2243307??2013-10-18?10:47??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\itext-4.2.1.jar
?????文件??????157360??2013-10-18?10:46??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\itext-rtf-2.1.7.jar
?????文件???????72229??2013-10-18?10:47??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\itext-rups-2.1.7.jar
?????文件??????331811??2014-03-27?09:38??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\lib\iTextAsian.jar
?????文件???????13862??2013-10-20?23:53??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\pfd大量數(shù)據(jù)的表格及水印開發(fā)文檔.docx
?????目錄???????????0??2014-03-27?10:25??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\
?????文件?????????483??2013-10-18?12:10??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\.classpath
?????文件?????????383??2013-10-18?10:19??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\.project
?????目錄???????????0??2013-10-21?00:00??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\
?????目錄???????????0??2013-10-21?00:00??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\
?????目錄???????????0??2013-10-21?00:00??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\
?????目錄???????????0??2013-10-21?00:00??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\
?????目錄???????????0??2014-03-27?10:25??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\util\
?????文件???????14350??2013-10-20?23:09??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\util\PDFCreate1File.java
?????文件???????16335??2013-10-20?21:41??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\util\PDFCreate2Table.java
?????文件???????29857??2013-10-20?23:31??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\util\PDFCreate2WaterMark.java
?????文件????????5697??2013-10-20?23:42??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\util\PdfFileExport.java
?????文件????????9656??2013-10-20?23:28??Javaweb項(xiàng)目pdf導(dǎo)出表格數(shù)據(jù)及水印操作的項(xiàng)目和jar包\testpdf\src\com\fruitking\testpdf\util\PdfFileExportUtil.java
評論
共有 條評論