導航:首頁 > 編程語言 > java極限編程pdf

java極限編程pdf

發布時間:2024-03-29 14:05:20

⑴ 如何運用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文件寫入不進去

通常需要用到用於讀、寫、編輯PDF文件的庫,你可以參考下面採用spire.pdf.jar來創建PDF的步驟及方法:

  1. 首先需要引入jar包。具體的引入方法可以自行網路搜索。

  2. 創建PdfDocument類的對象,並通過PdfDocument.getPages().add()方法添加頁碼。

  3. 定義標題文字。

  4. 創建PdfSolidBrush畫刷、PdfTrueTypeFont字體、PdfStringFormat字元串、Rectangle2D等對象,用於指定字元串繪制效果、字體、格式、繪制區域等。

  5. 通過PdfPageBase.getCanvas().drawString(body, font2, brush2, rect, format2)方法將內容繪制到PDF頁面。

下面附上詳細的代碼demo示例:

import com.spire.pdf.*;

import com.spire.pdf.graphics.*;

import java.awt.*;

import java.awt.geom.*;

import java.io.*;

public class CreatePdfDocumentInJava {

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

//創建PdfDocument對象
PdfDocument doc = new PdfDocument();

//添加一頁
PdfPageBase page = doc.getPages().add();

//標題文字
String title = "Java基礎語法";

//創建單色畫刷對象
PdfSolidBrush brush1 = new PdfSolidBrush(new PdfRGBColor(Color.BLUE));
PdfSolidBrush brush2 = new PdfSolidBrush(new PdfRGBColor(Color.BLACK));

//創建TrueType字體對象
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("宋體", Font.PLAIN, 14), true);
PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("宋體", Font.PLAIN, 10), true);

//創建PdfStringFormat對象
PdfStringFormat format1 = new PdfStringFormat();
format1.setAlignment(PdfTextAlignment.Center);//設置文字居中

//使用drawString方法繪制標題文字
page.getCanvas().drawString(title, font1, brush1, new Point2D.Float((float) page.getActualBounds(true).getWidth() / 2, 0), format1);

//從txt文件讀取內容到字元串
String body = readFileToString("C:\Users\Administrator\Desktop\bodyText.txt");

//創建PdfStringFormat對象
PdfStringFormat format2 = new PdfStringFormat();
format2.setParagraphIndent(20);//設置段首縮進

//創建Rectangle2D對象
Rectangle2D.Float rect = new Rectangle2D.Float(0, 30, (float) page.getActualBounds(true).getWidth(), (float) page.getActualBounds(true).getHeight());

//使用drawString方法在矩形區域繪制主體文字
page.getCanvas().drawString(body, font2, brush2, rect, format2);

//保存到PDF文檔
doc.saveToFile("ouput.pdf");
}

//自定義方法讀取txt文件內容到字元串
private static String readFileToString(String filepath) throws FileNotFoundException, IOException {

StringBuilder sb = new StringBuilder();
String s = "";
BufferedReader br = new BufferedReader(new FileReader(filepath));

while ((s = br.readLine()) != null) {
sb.append(s + " ");
}
br.close();
String str = sb.toString();
return str;
}

}

⑶ java解析pdf文件,求大神提供代碼,請注意是java語言的

給你提供一個參考例子,你可以在這個例子上試試,修改修改。也是解析PDF的。

importjava.io.File;
importjava.io.FileOutputStream;
importjava.io.OutputStreamWriter;
importjava.io.Writer;
importjava.net.MalformedURLException;
importjava.net.URL;
importorg.apache.pdfbox.pdmodel.PDDocument;
importorg.apache.pdfbox.util.PDFTextStripper;
publicclassPdfReader{
publicvoidreadFdf(Stringfile)throwsException{
//是否排序
booleansort=false;
//pdf文件名
StringpdfFile=file;
//輸入文本文件名稱
StringtextFile=null;
//編碼方式
Stringencoding="UTF-8";
//開始提取頁數
intstartPage=1;
//結束提取頁數
intendPage=Integer.MAX_VALUE;
//文件輸入流,生成文本文件
Writeroutput=null;
//內存中存儲的PDFDocument
PDDocumentdocument=null;
try{
try{
//首先當作一個URL來裝載文件,如果得到異常再從本地文件系統//去裝載文件
URLurl=newURL(pdfFile);
//注意參數已不是以前版本中的URL.而是File。
document=PDDocument.load(pdfFile);
//獲取PDF的文件名
StringfileName=url.getFile();
//以原來PDF的名稱來命名新產生的txt文件
if(fileName.length()>4){
FileoutputFile=newFile(fileName.substring(0,fileName
.length()-4)
+".txt");
textFile=outputFile.getName();
}
}catch(MalformedURLExceptione){
//如果作為URL裝載得到異常則從文件系統裝載
//注意參數已不是以前版本中的URL.而是File。
document=PDDocument.load(pdfFile);
if(pdfFile.length()>4){
textFile=pdfFile.substring(0,pdfFile.length()-4)
+".txt";
}
}
//文件輸入流,寫入文件倒textFile
output=newOutputStreamWriter(newFileOutputStream(textFile),
encoding);
//PDFTextStripper來提取文本
PDFTextStripperstripper=null;
stripper=newPDFTextStripper();
//設置是否排序
stripper.setSortByPosition(sort);
//設置起始頁
stripper.setStartPage(startPage);
//設置結束頁
stripper.setEndPage(endPage);
//調用PDFTextStripper的writeText提取並輸出文本
stripper.writeText(document,output);
}finally{
if(output!=null){
//關閉輸出流
output.close();
}
if(document!=null){
//關閉PDFDocument
document.close();
}
}
}
/**
*@paramargs
*/
publicstaticvoidmain(String[]args){
//TODOAuto-generatedmethodstub
PdfReaderpdfReader=newPdfReader();
try{
//取得E盤下的SpringGuide.pdf的內容
pdfReader.readFdf("d:\b.pdf");
}catch(Exceptione){
e.printStackTrace();
}
}
}

⑷ 如何運用Java組件itext生成pdf

實現流程:
一、iText介紹
iText是著名的開放源碼的站點sourceforge一個項目,是用於生成PDF文檔的一個java類庫。通過iText不僅可以生成PDF或rtf的文檔,而且可以將XML、Html文件轉化為PDF文件。
二、建立第一個PDF文檔
用iText生成PDF文檔需要5個步驟:
①建立com.lowagie.text.Document對象的實例。
Document document = new Document();
②建立一個書寫器(Writer)與document對象關聯,通過書寫器(Writer)可以將文檔寫入到磁碟中。
PDFWriter.getInstance(document, new FileOutputStream("Helloworld.PDF"));
③打開文檔。
document.open();
④向文檔中添加內容。
document.add(new Paragraph("Hello World"));
⑤關閉文檔。
document.close();
通過上面的5個步驟,就能產生一個Helloworld.PDF的文件,文件內容為"Hello World"。
建立com.lowagie.text.Document對象的實例
com.lowagie.text.Document對象的構建函數有三個,分別是:
public Document();
public Document(Rectangle pageSize);
public Document(Rectangle pageSize,
int marginLeft,
int marginRight,
int marginTop,
int marginBottom);
構建函數的參數pageSize是文檔頁面的大小,對於第一個構建函數,頁面的大小為A4,同Document(PageSize.A4)的效果一樣;
對於第三個構建函數,參數marginLeft、marginRight、marginTop、marginBottom分別為左、右、上、下的頁邊距。
通過參數pageSize可以設定頁面大小、面背景色、以及頁面橫向/縱向等屬性。iText定義了A0-A10、AL、LETTER、
HALFLETTER、_11x17、LEDGER、NOTE、B0-B5、ARCH_A-ARCH_E、FLSA
和FLSE等紙張類型,也可以通過Rectangle pageSize = new Rectangle(144,
720);自定義紙張。通過Rectangle方法rotate()可以將頁面設置成橫向。
書寫器(Writer)對象
一旦文檔(document)對象建立好之後,需要建立一個或多個書寫器(Writer)對象與之關聯。通過書寫器(Writer)對象可以將具體文檔
存檔成需要的格式,如com.lowagie.text.PDF.PDFWriter可以將文檔存成PDF文件,
com.lowagie.text.html.HtmlWriter可以將文檔存成html文件。
設定文檔屬性
在文檔打開之前,可以設定文檔的標題、主題、作者、關鍵字、裝訂方式、創建者、生產者、創建日期等屬性,調用的方法分別是:
public boolean addTitle(String title)
public boolean addSubject(String subject)
public boolean addKeywords(String keywords)
public boolean addAuthor(String author)
public boolean addCreator(String creator)
public boolean addProcer()
public boolean addCreationDate()
public boolean addHeader(String name, String content)
其中方法addHeader對於PDF文檔無效,addHeader僅對html文檔有效,用於添加文檔的頭信息。
當新的頁面產生之前,可以設定頁面的大小、書簽、腳注(HeaderFooter)等信息,調用的方法是:
public boolean setPageSize(Rectangle pageSize)
public boolean add(Watermark watermark)
public void removeWatermark()
public void setHeader(HeaderFooter header)
public void resetHeader()
public void setFooter(HeaderFooter footer)
public void resetFooter()
public void resetPageCount()
public void setPageCount(int pageN)
如果要設定第一頁的頁面屬性,這些方法必須在文檔打開之前調用。
對於PDF文檔,iText還提供了文檔的顯示屬性,通過調用書寫器的setViewerPreferences方法可以控制文檔打開時Acrobat Reader的顯示屬性,如是否單頁顯示、是否全屏顯示、是否隱藏狀態條等屬性。
另外,iText也提供了對PDF文件的安全保護,通過書寫器(Writer)的setEncryption方法,可以設定文檔的用戶口令、只讀、可列印等屬性。
添加文檔內容
所有向文檔添加的內容都是以對象為單位的,如Phrase、Paragraph、Table、Graphic對象等。比較常用的是段落(Paragraph)對象,用於向文檔中添加一段文字。
三、文本處理
iText中用文本塊(Chunk)、短語(Phrase)和段落(paragraph)處理文本。
文本塊(Chunk)是處理文本的最小單位,有一串帶格式(包括字體、顏色、大小)的字元串組成。如以下代碼就是產生一個字體為HELVETICA、大小為10、帶下劃線的字元串:
Chunk chunk1 = new Chunk("This text is underlined", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE));
短語(Phrase)由一個或多個文本塊(Chunk)組成,短語(Phrase)也可以設定字體,但對於其中以設定過字體的文本塊
(Chunk)無效。通過短語(Phrase)成員函數add可以將一個文本塊(Chunk)加到短語(Phrase)中,
如:phrase6.add(chunk);
段落(paragraph)由一個或多個文本塊(Chunk)或短語(Phrase)組
成,相當於WORD文檔中的段落概念,同樣可以設定段落的字體大小、顏色等屬性。另外也可以設定段落的首行縮進、對齊方式(左對齊、右對齊、居中對齊)。
通過函數setAlignment可以設定段落的對齊方式, setAlignment的參數1為居中對齊、2為右對齊、3為左對齊,默認為左對齊。
四、表格處理
iText中處理表格的類為:com.lowagie.text.Table和com.lowagie.text.PDF.PDFPTable,對於比
較簡單的表格處理可以用com.lowagie.text.Table,但是如果要處理復雜的表格,這就需要
com.lowagie.text.PDF.PDFPTable進行處理。這里就類com.lowagie.text.Table進行說明。
類com.lowagie.text.Table的構造函數有三個:
①Table (int columns)
②Table(int columns, int rows)
③Table(Properties attributes)
參數columns、rows、attributes分別為表格的列數、行數、表格屬性。創建表格時必須指定表格的列數,而對於行數可以不用指定。
建立表格之後,可以設定表格的屬性,如:邊框寬度、邊框顏色、襯距(padding space 即單元格之間的間距)大小等屬性。下面通過一個簡單的例子說明如何使用表格,代碼如下:
1:Table table = new Table(3);
2:table.setBorderWidth(1);
3:table.setBorderColor(new Color(0, 0, 255));
4:table.setPadding(5);
5:table.setSpacing(5);
6:Cell cell = new Cell("header");
7:cell.setHeader(true);
8:cell.setColspan(3);
9:table.addCell(cell);
10:table.endHeaders();
11:cell = new Cell("example cell with colspan 1 and rowspan 2");
12:cell.setRowspan(2);
13:cell.setBorderColor(new Color(255, 0, 0));
14:table.addCell(cell);
15:table.addCell("1.1");
16:table.addCell("2.1");
17:table.addCell("1.2");
18:table.addCell("2.2");
19:table.addCell("cell test1");
20:cell = new Cell("big cell");
21:cell.setRowspan(2);
22:cell.setColspan(2);
23:table.addCell(cell);
24:table.addCell("cell test2");
運行結果如下:
header
example cell with colspan 1 and rowspan 2 1.1 2.1
1.2 2.2
cell test1 big cell
cell test2
代碼1-5行用於新建一個表格,如代碼所示,建立了一個列數為3的表格,並將邊框寬度設為1,顏色為藍色,襯距為5。
代碼6-10行用於設定表格的表頭,第7行cell.setHeader(true);是將該單元格作為表頭信息顯示;第8行
cell.setColspan(3);指定了該單元格佔3列;為表格添加表頭信息時,要注意的是一旦表頭信息添加完了之後,必須調用
endHeaders()方法,如第10行,否則當表格跨頁後,表頭信息不會再顯示。
代碼11-14行是向表格中添加一個寬度佔一列,長度佔二行的單元格。
往表格中添加單元格(cell)時,按自左向右、從上而下的次序添加。如執行完11行代碼後,表格的右下方出現2行2列的空白,這是再往表格添加單元格時,先填滿這個空白,然後再另起一行,15-24行代碼說明了這種添加順序。
五、圖像處理
iText中處理表格的類為com.lowagie.text.Image,目前iText支持的圖像格式有:GIF, Jpeg, PNG,
wmf等格式,對於不同的圖像格式,iText用同樣的構造函數自動識別圖像格式。通過下面的代碼分別獲得gif、jpg、png圖像的實例。
Image gif = Image.getInstance("vonnegut.gif");
Image jpeg = Image.getInstance("myKids.jpg");
Image png = Image.getInstance("hitchcock.png");
圖像的位置
圖像的位置主要是指圖像在文檔中的對齊方式、圖像和文本的位置關系。IText中通過函數public void setAlignment(int
alignment)進行處理,參數alignment為Image.RIGHT、Image.MIDDLE、Image.LEFT分別指右對齊、居中、
左對齊;當參數alignment為Image.TEXTWRAP、Image.UNDERLYING分別指文字繞圖形顯示、圖形作為文字的背景顯示。這
兩種參數可以結合以達到預期的效果,如setAlignment(Image.RIGHT|Image.TEXTWRAP)顯示的效果為圖像右對齊,文字
圍繞圖像顯示。
圖像的尺寸和旋轉
如果圖像在文檔中不按原尺寸顯示,可以通過下面的函數進行設定:
public void scaleAbsolute(int newWidth, int newHeight)
public void scalePercent(int percent)
public void scalePercent(int percentX, int percentY)
函數public void scaleAbsolute(int newWidth, int
newHeight)直接設定顯示尺寸;函數public void scalePercent(int
percent)設定顯示比例,如scalePercent(50)表示顯示的大小為原尺寸的50%;而函數scalePercent(int
percentX, int percentY)則圖像高寬的顯示比例。
如果圖像需要旋轉一定角度之後在文檔中顯示,可以通過函數public void setRotation(double r)設定,參數r為弧度,如果旋轉角度為30度,則參數r= Math.PI / 6。
六、中文處理
默認的iText字體設置不支持中文字體,需要下載遠東字體包iTextAsian.jar,否則不能往PDF文檔中輸出中文字體。通過下面的代碼就可以在文檔中使用中文了:
BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 12, com.lowagie.text.Font.NORMAL);
Paragraph pragraph=new Paragraph("你好", FontChinese);

⑸ java代碼doc轉pdf提高效率的方法

使用了jacob.jar來調用activex控制項,本機需安裝WPS或pdfcreator
001 package experiments;
002
003 import com.jacob.activeX.ActiveXComponent;
004 import com.jacob.com.Dispatch;
005 import com.jacob.com.DispatchEvents;
006 import com.jacob.com.Variant;
007 import java.io.File;
008 import java.util.logging.Level;
009 import java.util.logging.Logger;
010
011 public class Doc2Pdf {
012
013 public static Converter newConverter(String name) {
014 if (name.equals("wps")) {
015 return new Wps();
016 } else if (name.equals("pdfcreator")) {
017 return new PdfCreator();
018 }
019 return null;
020 }
021
022 public synchronized static boolean convert(String word, String pdf) {
023 return newConverter("pdfcreator").convert(word, pdf);
024 }
025
026 public static interface Converter {
027
028 public boolean convert(String word, String pdf);
029 }
030
031 public static class Wps implements Converter {
032
033 public synchronized boolean convert(String word, String pdf) {
034 File pdfFile = new File(pdf);
035 File wordFile = new File(word);
036 ActiveXComponent wps = null;
037 try {
038 wps = new ActiveXComponent("wps.application");
039 ActiveXComponent doc = wps.invokeGetComponent("Documents").invokeGetComponent("Open", newVariant(wordFile.getAbsolutePath()));
040 doc.invoke("ExportPdf", new Variant(pdfFile.getAbsolutePath()));
041 doc.invoke("Close");
042 doc.safeRelease();
043 } catch (Exception ex) {
044 Logger.getLogger(Doc2Pdf.class.getName()).log(Level.SEVERE, null, ex);
045 return false;
046 } catch (Error ex) {
047 Logger.getLogger(Doc2Pdf.class.getName()).log(Level.SEVERE, null, ex);
048 return false;
049 } finally {
050 if (wps != null) {
051 wps.invoke("Terminate");
052 wps.safeRelease();
053 }
054 }
055 return true;
056 }
057 }
058
059 public static class PdfCreator implements Converter {
060
061 public static final int STATUS_IN_PROGRESS = 2;
062 public static final int STATUS_WITH_ERRORS = 1;
063 public static final int STATUS_READY = 0;
064 private ActiveXComponent pdfCreator;
065 private DispatchEvents dispatcher;
066 private volatile int status;
067 private Variant defaultPrinter;
068
069 private void init() {
070 pdfCreator = new ActiveXComponent("PDFCreator.clsPDFCreator");
071 dispatcher = new DispatchEvents(pdfCreator, this);
072 pdfCreator.setProperty("cVisible", new Variant(false));
073 pdfCreator.invoke("cStart", new Variant[]{newVariant("/NoProcessingAtStartup"), new Variant(true)});
074 setCOption("UseAutosave", 1);
075 setCOption("UseAutosaveDirectory", 1);
076 setCOption("AutosaveFormat", 0); // 0 = PDF
077 defaultPrinter = pdfCreator.getProperty("cDefaultPrinter");
078 status = STATUS_IN_PROGRESS;
079 pdfCreator.setProperty("cDefaultprinter", "PDFCreator");
080 pdfCreator.invoke("cClearCache");
081 pdfCreator.setProperty("cPrinterStop", false);
082 }
083
084 private void setCOption(String property, Object value) {
085 Dispatch.invoke(pdfCreator, "cOption", Dispatch.Put, new Object[]{property, value}, new int[2]);
086 }
087
088 private void close() {
089 if (pdfCreator != null) {
090 pdfCreator.setProperty("cDefaultprinter", defaultPrinter);
091 pdfCreator.invoke("cClearCache");
092 pdfCreator.setProperty("cPrinterStop", true);
093 pdfCreator.invoke("cClose");
094 pdfCreator.safeRelease();
095 pdfCreator = null;
096 }
097 if (dispatcher != null) {
098 dispatcher.safeRelease();
099 dispatcher = null;
100 }
101 }
102
103 public synchronized boolean convert(String word, String pdf) {
104 File pdfFile = new File(pdf);
105 File wordFile = new File(word);
106 try {
107 init();
108 setCOption("AutosaveDirectory", pdfFile.getParentFile().getAbsolutePath());
109 if (pdfFile.exists()) {
110 pdfFile.delete();
111 }
112 pdfCreator.invoke("cPrintfile", wordFile.getAbsolutePath());
113 int seconds = 0;
114 while (isInProcess()) {
115 seconds++;
116 if (seconds > 30) { // timeout
117 throw new Exception("convertion timeout!");
118 }
119 Thread.sleep(1000);
120 }
121 if (isWithErrors()) return false;
122 // 由於轉換前設置cOption的AutosaveFilename不能保證輸出的文件名與設置的相同(pdfcreator會加入/修改後綴名)
123 // 所以這里讓pdfcreator使用自動生成的文件名進行輸出,然後在保存後將其重命名為目標文件名
124 File outputFile = newFile(pdfCreator.getPropertyAsString("cOutputFilename"));
125 if (outputFile.exists()) {
126 outputFile.renameTo(pdfFile);
127 }
128 } catch (InterruptedException ex) {
129 Logger.getLogger(Doc2Pdf.class.getName()).log(Level.SEVERE, null, ex);
130 return false;
131 } catch (Exception ex) {
132 Logger.getLogger(Doc2Pdf.class.getName()).log(Level.SEVERE, null, ex);
133 return false;
134 } catch (Error ex) {
135 Logger.getLogger(Doc2Pdf.class.getName()).log(Level.SEVERE, null, ex);
136 return false;
137 } finally {
138 close();
139 }
140 return true;
141 }
142
143 private boolean isInProcess() {
144 return status == STATUS_IN_PROGRESS;
145 }
146
147 private boolean isWithErrors() {
148 return status == STATUS_WITH_ERRORS;
149 }
150
151 // eReady event
152 public void eReady(Variant[] args) {
153 status = STATUS_READY;
154 }
155
156 // eError event
157 public void eError(Variant[] args) {
158 status = STATUS_WITH_ERRORS;
159 }
160 }
161
162 public static void main(String[] args) {
163 convert("e:\\test.doc", "e:\\output.pdf");
164 }
165 }

⑹ java中如何實現向已有的PDF文件插入附件

可以用Spire.Pdf for Java類庫給PDF文檔添加附件,下面的代碼是插入Excel和Word附件給你參考:

import com.spire.pdf.annotations.*;

import com.spire.pdf.attachments.PdfAttachment;

import com.spire.pdf.graphics.*;

import java.awt.*;

import java.awt.geom.Dimension2D;

import java.awt.geom.Rectangle2D;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

public class AttachFiles {
public static void main(String[] args) throws IOException {


//創建PdfDocument對象


PdfDocument doc = new PdfDocument();


//載入PDF文檔


doc.loadFromFile("C:\Users\Administrator\Desktop\sample.pdf");


//添加附件到PDF


PdfAttachment attachment = new PdfAttachment("C:\Users\Administrator\Desktop\使用說明書.docx");


doc.getAttachments().add(attachment);


//繪制標簽

String label = "財務報表.xlsx";


PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial Unicode MS",Font.PLAIN,12),true);


double x = 35;


double y = doc.getPages().get(0).getActualSize().getHeight() - 200;


doc.getPages().get(0).getCanvas().drawString(label, font, PdfBrushes.getOrange(), x, y);

//添加註釋附件到PDF


String filePath = "C:\Users\Administrator\Desktop\財務報表.xlsx";


byte[] data = toByteArray(filePath);


Dimension2D size = font.measureString(label);


Rectangle2D bound = new Rectangle2D.Float((float) (x + size.getWidth() + 2), (float) y, 10, 15);


PdfAttachmentAnnotation annotation = new PdfAttachmentAnnotation(bound, filePath, data);


annotation.setColor(new PdfRGBColor(new Color(0, 128, 128)));


annotation.setFlags(PdfAnnotationFlags.Default);


annotation.setIcon(PdfAttachmentIcon.Graph);


annotation.setText("點擊打開財務報表.xlsx");


doc.getPages().get(0).getAnnotationsWidget().add(annotation);

//保存文檔


doc.saveToFile("Attachments.pdf");
}

//讀取文件到byte數組


public static byte[] toByteArray(String filePath) throws IOException {

File file = new File(filePath);


long fileSize = file.length();


if (fileSize > Integer.MAX_VALUE) {


System.out.println("file too big...");


return null;


}


FileInputStream fi = new FileInputStream(file);


byte[] buffer = new byte[(int) fileSize];


int offset = 0;


int numRead = 0;


while (offset < buffer.length && (numRead = fi.read(buffer, offset, buffer.length - offset)) >= 0) {


offset += numRead;


}

if (offset != buffer.length) {


throw new IOException("Could not completely read file "
+ file.getName());


}


fi.close();


return buffer;


}


}

效果:

⑺ java處理pdf文件

FileInputStream 讀取文件流就OK 至於在頁面顯示

1、客戶機上要有PDF2、URL url =new URL("file:///"+ 你的文件路徑);response.setContentType(url.openConnection().getContentType());response.setHeader("Content-Disposition", "inline; filename="+ 文件名);或在jsp頁面中加入 <% response.setHeader("Content-disposition", "attachment; filename=*.pdf"); %> 以上會提示下載、保存 <% response.setHeader("Content-disposition", "filename=*.pdf"); %> 不要attachment; 就會直接打開,顯示pdf了

⑻ 如何運用Java組件itext生成pdf

Controller層(param為數據)

byte[]bytes=PdfUtils.createPdf(param);
ByteArrayInputStreaminStream=newByteArrayInputStream(bytes);
//設置輸出的格式
response.setContentType("bin");
response.setHeader("content-disposition","attachment;filename="+URLEncoder.encode(itemName+"(評審意見).pdf","UTF-8"));
//循環取出流中的數據
byte[]b=newbyte[2048];
intlen;
while((len=inStream.read(b))>0)
response.getOutputStream().write(b,0,len);

inStream.close();

Service層(param為數據)

public static byte[] createPdf(Map<String,Object> param) {

byte[] result= null;

ByteArrayOutputStream baos = null;

//支流程評審信息匯總

List<CmplncBranchRvwInfoDTO> branchRvwInfos = (List<CmplncBranchRvwInfoDTO>) param.get("branchRvwInfos");

//主流程評審信息匯總

List<CmplncMainRvwInfoDTO> mainRvwInfos = (List<CmplncMainRvwInfoDTO>) param.get("mainRvwInfos");

//主評審信息

CmplncRvwFormDTO rvwFormDTO = (CmplncRvwFormDTO) param.get("rvwFormDTO");

//附件列表

List<FileInfoDTO> fileList = (List<FileInfoDTO>) param.get("fileList");

//專業公司

String legalEntityDeptDesc = (String) param.get("legalEntityDeptDesc");

String legalEntitySonDeptDesc = (String) param.get("legalEntitySonDeptDesc");

//設置頁邊距

Document doc = new Document(PageSize.A4, 20, 20, 60, 20);

try {

baos = new ByteArrayOutputStream();//構建位元組輸出流

PdfWriter writer = PdfWriter.getInstance(doc,baos);

//頁眉頁腳字體

BaseFont bf = null;

BaseFont bFont = null;

try {

bFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);

bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H",BaseFont.NOT_EMBEDDED);

} catch (Exception e) {

e.printStackTrace();

}

Font footerFont = new Font(bFont, 10, Font.NORMAL);

Font title = new Font(bf,15,Font.BOLD);

Font content = new Font(bf,9,Font.NORMAL);

Font chinese = new Font(bf, 10, Font.BOLD);

/**

* HeaderFooter的第2個參數為非false時代表列印頁碼

* 頁眉頁腳中也可以加入圖片,並非只能是文字

*/

HeaderFooter header=new HeaderFooter(new Phrase("法律合規評審系統",title),false);

//設置是否有邊框等

header.setBorder(Rectangle.NO_BORDER);

header.setAlignment(1);

doc.setHeader(header);

HeaderFooter footer=new HeaderFooter(new Phrase("-",footerFont),new Phrase("-",footerFont));

/**

* 0左 1中 2右

*/

footer.setAlignment(1);

footer.setBorder(Rectangle.NO_BORDER);

doc.setFooter(footer);

doc.open();

//doc.add(new Paragraph("評審意見:",chinese));

//7列

PdfPTable table = new PdfPTable(7);

PdfPCell cell;

table.addCell(new Paragraph("評審項目編號",chinese));

table.addCell(new Paragraph(rvwFormDTO.getRvwItemCode(),content));

cell = new PdfPCell(new Paragraph("評審項目類型",chinese));

cell.setColspan(2);

table.addCell(cell);

String rvwItemParentType = (String) param.get("rvwItemParentType");

String rvwItemType = (String) param.get("rvwItemType");

String rvwItemTwoType = (String) param.get("rvwItemTwoType");

cell = new PdfPCell(new Paragraph(rvwItemParentType+"/"+rvwItemType+"/"+rvwItemTwoType,content));

cell.setColspan(3);

table.addCell(cell);

table.addCell(new Paragraph("申請人姓名",chinese));

table.addCell(new Paragraph(rvwFormDTO.getApplicantName(),content));

cell = new PdfPCell(new Paragraph("申請人所在部門",chinese));

cell.setColspan(2);

table.addCell(cell);

cell = new PdfPCell(new Paragraph(rvwFormDTO.getAplcntDeptName(),content));

cell.setColspan(3);

table.addCell(cell);

table.addCell(new Paragraph("錄入人姓名",chinese));

table.addCell(new Paragraph(rvwFormDTO.getRecordName(),content));

cell = new PdfPCell(new Paragraph("項目涉及金額",chinese));

cell.setColspan(2);

table.addCell(cell);

table.addCell(new Paragraph(String.valueOf(rvwFormDTO.getInvolveAmount()==null?0:rvwFormDTO.getInvolveAmount()),content));

table.addCell(new Paragraph("幣種",chinese));

String involveAmountType = (String) param.get("involveAmountType");

table.addCell(new Paragraph(involveAmountType,content));

table.addCell(new Paragraph("專業公司",chinese));

cell = new PdfPCell(new Paragraph(legalEntityDeptDesc+"->"+legalEntitySonDeptDesc,content));

cell.setColspan(6);

table.addCell(cell);

table.addCell(new Paragraph("項目名稱",chinese));

cell = new PdfPCell(new Paragraph(rvwFormDTO.getItemName(),content));

cell.setColspan(6);

table.addCell(cell);

table.addCell(new Paragraph("項目概述",chinese));

cell = new PdfPCell(new Paragraph(rvwFormDTO.getItemOverview(),content));

cell.setColspan(6);

table.addCell(cell);

table.addCell(new Paragraph("評審需求",chinese));

cell = new PdfPCell(new Paragraph(rvwFormDTO.getRvwDemand(),content));

cell.setColspan(6);

table.addCell(cell);

table.addCell(new Paragraph("申請人自我評估",chinese));

cell = new PdfPCell(new Paragraph(rvwFormDTO.getApplicantSelfAssmnt(),content));

cell.setColspan(6);

table.addCell(cell);

/* table.addCell(new Paragraph("同步抄送",chinese));

cell = new PdfPCell(new Paragraph(rvwFormDTO.getSyncsenderNames(),content));

cell.setColspan(6);

table.addCell(cell);*/

int infoNum = 0;

if(fileList.size() > 0){

//附件信息

cell = new PdfPCell(new Paragraph("附件信息",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

cell.setRowspan(fileList.size()+1);

table.addCell(cell);

//序號

cell = new PdfPCell(new Paragraph("序號",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//附件名稱

cell = new PdfPCell(new Paragraph("附件名稱",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//上傳時間

cell = new PdfPCell(new Paragraph("上傳時間",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//上傳人

cell = new PdfPCell(new Paragraph("上傳人",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//附件類型

cell = new PdfPCell(new Paragraph("附件類型",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//法律合規評審

cell = new PdfPCell(new Paragraph("法律合規評審",chinese));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

for (FileInfoDTO file : fileList) {

infoNum++;

//序號

cell = new PdfPCell(new Paragraph(infoNum+"",content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//附件名稱

cell = new PdfPCell(new Paragraph(file.getFileName(),content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//上傳時間

cell = new PdfPCell(new Paragraph(file.getUploadTimeFormat(),content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//上傳人

cell = new PdfPCell(new Paragraph(file.getUploadName(),content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//附件類型

String fileType;

if("1".equals(file.getFileType())){

fileType = "合同文件";

}else if("99".equals(file.getFileType())){

fileType = "支持文檔";

}else{

fileType = "";

}

cell = new PdfPCell(new Paragraph(fileType,content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//法律合規評審

String typeRvwStatus;

if("1".equals(file.getTypeRvwStatus())){

typeRvwStatus = "經審查附件無重大法律合規問題";

}else if("2".equals(file.getTypeRvwStatus())){

typeRvwStatus = "退回修改";

}else{

typeRvwStatus = "";

}

cell = new PdfPCell(new Paragraph(typeRvwStatus,content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

}

}else{

//附件信息

cell = new PdfPCell(new Paragraph("附件信息",chinese));

table.addCell(cell);

cell = new PdfPCell(new Paragraph("沒有附件",content));

cell.setColspan(6);

table.addCell(cell);

}

cell = new PdfPCell(new Paragraph("評審意見",chinese));

cell.setRowspan(mainRvwInfos.size()+branchRvwInfos.size());

//居中

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

if(mainRvwInfos.size()>0){

cell = new PdfPCell(new Paragraph("主評審意見",chinese));

cell.setRowspan(mainRvwInfos.size());

//居中

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

infoNum = 0;

for (CmplncMainRvwInfoDTO dto : mainRvwInfos) {

infoNum++;

//序號

cell = new PdfPCell(new Paragraph(infoNum+"",content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//評審意見

PdfPTable branchRvwInfosTable = new PdfPTable(1);

cell = new PdfPCell(new Paragraph(delHTMLTag(dto.getRvwOpinion()),content));

cell.disableBorderSide(2);

branchRvwInfosTable.addCell(cell);

//評審人和評審時間

cell = new PdfPCell(new Paragraph(dto.getRvwUmName()+"/"+getStringDate(dto.getRvwTime()),content));

cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

cell.disableBorderSide(1);

cell.setPaddingTop(5);

branchRvwInfosTable.addCell(cell);

PdfPCell branchRvwInfosCell = new PdfPCell(branchRvwInfosTable);

branchRvwInfosCell.setColspan(4);

table.addCell(branchRvwInfosCell);

}

doc.add(table);

}

if(branchRvwInfos.size()>0){

cell = new PdfPCell(new Paragraph("支評審意見",chinese));

cell.setRowspan(branchRvwInfos.size());

//居中

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

infoNum = 0;

for (CmplncBranchRvwInfoDTO dto : branchRvwInfos) {

infoNum++;

//序號

cell = new PdfPCell(new Paragraph(infoNum+"",content));

cell.setUseAscender(true);

cell.setHorizontalAlignment(Element.ALIGN_CENTER); //水平居中

cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //垂直居中

table.addCell(cell);

//評審意見

PdfPTable branchRvwInfosTable = new PdfPTable(1);

cell = new PdfPCell(new Paragraph(delHTMLTag(dto.getRvwOpinion()),content));

cell.disableBorderSide(2);

branchRvwInfosTable.addCell(cell);

//評審人和評審時間

cell = new PdfPCell(new Paragraph(dto.getRvwUmName()+"/"+getStringDate(dto.getRvwTime()),content));

cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

cell.disableBorderSide(1);//隱藏上邊框

cell.setPaddingTop(5);

branchRvwInfosTable.addCell(cell);

PdfPCell branchRvwInfosCell = new PdfPCell(branchRvwInfosTable);

branchRvwInfosCell.setColspan(4);

table.addCell(branchRvwInfosCell);

}

doc.add(table);

}

if(doc != null){

doc.close();

}

result =baos.toByteArray();

} catch (DocumentException e) {

e.printStackTrace();

}finally{

if(baos != null){

try {

baos.close();

} catch (IOException e) {

log.error("PDF異常", e);

}

}

}

return result;

}

工具

/**

* 去掉HTML標簽

* @param htmlStr

* @return

*/

public static String delHTMLTag(String htmlStr){

if (htmlStr!=null){

String regEx_script="<script[^>]*?>[\s\S]*?<\/script>"; //定義script的正則表達式

String regEx_style="<style[^>]*?>[\s\S]*?<\/style>"; //定義style的正則表達式

String regEx_html="<[^>]+>"; //定義HTML標簽的正則表達式

Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);

Matcher m_script=p_script.matcher(htmlStr);

htmlStr=m_script.replaceAll(""); //過濾script標簽

Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);

Matcher m_style=p_style.matcher(htmlStr);

htmlStr=m_style.replaceAll(""); //過濾style標簽

Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);

Matcher m_html=p_html.matcher(htmlStr);

htmlStr=m_html.replaceAll(""); //過濾html標簽

Pattern p_enter = Pattern.compile("\s*| | | ");

Matcher m_enter = p_enter.matcher(htmlStr);

htmlStr = m_enter.replaceAll("");

}

return htmlStr.trim().replaceAll("&nbsp;", ""); //返迴文本字元串

}

/**

* @return返回字元串格式 yyyy-MM-dd HH:mm:ss

*/

public static String getStringDate(Date date) {

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String dateString = formatter.format(date);

return dateString;

}

⑼ 如何用純java代碼實現word轉pdf

幾種方案:
方法一:用apache pio 讀取doc文件,然後轉成html文件用Jsoup格式化html文件,最後用itext將html文件轉成pdf。

方法2:使用jdoctopdf來實現,這是一個封裝好的包,可以把doc轉換成pdf,html,xml等格式,調用很方便
地址:
需要注意中文字體的寫入問題。

方法3:使用jodconverter來調用openOffice的服務來轉換,openOffice有個各個平台的版本,所以這種方法跟方法1一樣都是跨平台的。
jodconverter的下載地址:
首先要安裝openOffice,下載地址:
安裝完後要啟動openOffice的服務,具體啟動方法請自行google

方法4:效果最好的一種方法,但是需要window環境,而且速度是最慢的需要安裝msofficeWord以及SaveAsPDFandXPS.exe(word的一個插件,用來把word轉化為pdf)
Office版本是2007,因為SaveAsPDFandXPS是微軟為office2007及以上版本開發的插件
SaveAsPDFandXPS下載地址:
jacob 包下載地址:

閱讀全文

與java極限編程pdf相關的資料

熱點內容
vlc命令 瀏覽:698
如何搜尋mc伺服器 瀏覽:947
論壇觸屏手機版文件夾是哪個 瀏覽:406
mac命令刪除文件夾 瀏覽:813
退休職工醫保怎麼演算法 瀏覽:739
免費愛情片中文字幕 瀏覽:566
linux判斷字元串為空 瀏覽:202
鬼片小電影在線 瀏覽:29
如何看搶版電影 瀏覽:967
粵語影視app推薦 瀏覽:465
電影營免費完整版 瀏覽:232
如何關閉app的推送通知 瀏覽:533
文件加密狗沒有密碼了 瀏覽:851
vs修改編譯時編碼 瀏覽:463
韓國音樂老師電影 瀏覽:523
校園喪屍爆發小說 瀏覽:100
動漫分娩片段 瀏覽:159
東方財富app怎麼查看股票發行價 瀏覽:549
鏟車空調壓縮機支架 瀏覽:348
寶書網手機版txt官網 瀏覽:888