openoffice 轉換各種文件

Java代碼
1.2010-07-30 11:01
2.
3.此頁由Linux Wiki用戶Chenxing於2008年3月11日 (星期二) 10:45的最後更改。
4.出自Linux Wiki
5.在Linux中常常涉及到多種文檔格式,如doc、txt、html、rtf等等。爲了方便文件傳遞,就可能需要在各種格式之間進行轉換。 OpenOffice.Org可以方便的打開多各文檔格式並按需進行轉換,但要一次處理大量文件或要編寫腳本進行轉換時,僅用OpenOffice就難以勝任了。
6.
7.unoconv利用OpenOffice.Org的UNO接口實現了命令行文檔格式轉換功能,支持所有OpenOffice支持的文件格式,爲文檔的批量轉換提供了可能。
8.
9.目錄
10.[隱藏]
11.•1 下載及安裝
12.•2 使用方法
13.◦2.1 單個文件轉換
14.◦2.2 批量轉換
15.•3 其它功能簡介
16.◦3.1 支持的文件格式
17.◦3.2 服務器/客戶端模式
18.•4 附:支持的輸出文件格式
19.•5 相關資料
20.
21.下載及安裝
22.目前Debian的源已經有unoconv,如果你使用的發行版還沒有unoconv,可以到它的主頁下載: http://dag.wieers.com/home-made/unoconv/ 。
23.
24.注意:
25.該軟件依賴於OpenOffice.Org。
26.使用方法
27.單個文件轉換
28.舉一個例子:要轉換一個doc文件爲PDF格式,只需在命令中執行:
29.
30.$ unoconv -f pdf myDoc.doc
31.即會生成一個名爲myDoc.pdf的pdf文件。
32.
33.批量轉換
34.批量轉換需要結合find命令或腳本使用,使用時需注意最好使用C/S模式以加快速度:
35.
36.unoconv --listener &
37.unoconv -f pdf some-document.odt
38.unoconv -f doc other-document.odt
39.unoconv -f jpg some-image.png
40.unoconv -f xsl some-spreadsheet.csv
41.其它功能簡介
42.支持的文件格式
43.可以執行unoconv --show查看截止到2008年3月11日,unoconv支持以下幾種導出格式(見本文末尾)[1]
44.
45.服務器/客戶端模式
46.此模式使文檔的集中處理成爲可能。
47.
48.附:支持的輸出文件格式
49.bib - BibTeX [.bib]
50.doc - Microsoft Word 97/2000/XP [.doc]
51.doc6 - Microsoft Word 6.0 [.doc]
52.doc95 - Microsoft Word 95 [.doc]
53.docbook - DocBook [.xml]
54.html - HTML Document (OpenOffice.org Writer) [.html]
55.odt - Open Document Text [.odt]
56.ott - Open Document Text [.ott]
57.ooxml - Microsoft Office Open XML [.xml]
58.pdb - AportisDoc (Palm) [.pdb]
59.pdf - Portable Document Format [.pdf]
60.psw - Pocket Word [.psw]
61.rtf - Rich Text Format [.rtf]
62.latex - LaTeX 2e [.ltx]
63.sdw - StarWriter 5.0 [.sdw]
64.sdw4 - StarWriter 4.0 [.sdw]
65.sdw3 - StarWriter 3.0 [.sdw]
66.stw - Open Office.org 1.0 Text Document Template [.stw]
67.sxw - Open Office.org 1.0 Text Document [.sxw]
68.text - Text Encoded [.txt]
69.txt - Plain Text [.txt]
70.vor - StarWriter 5.0 Template [.vor]
71.vor4 - StarWriter 4.0 Template [.vor]
72.vor3 - StarWriter 3.0 Template [.vor]
73.xhtml - XHTML Document [.html]
74.圖形格式:
75.
76.bmp - Windows Bitmap [.bmp]
77.emf - Enhanced Metafile [.emf]
78.eps - Encapsulated PostScript [.eps]
79.gif - Graphics Interchange Format [.gif]
80.html - HTML Document (OpenOffice.org Draw) [.html]
81.jpg - Joint Photographic Experts Group [.jpg]
82.met - OS/2 Metafile [.met]
83.odd - OpenDocument Drawing [.odd]
84.otg - OpenDocument Drawing Template [.otg]
85.pbm - Portable Bitmap [.pbm]
86.pct - Mac Pict [.pct]
87.pdf - Portable Document Format [.pdf]
88.pgm - Portable Graymap [.pgm]
89.png - Portable Network Graphic [.png]
90.ppm - Portable Pixelmap [.ppm]
91.ras - Sun Raster Image [.ras]
92.std - OpenOffice.org 1.0 Drawing Template [.std]
93.svg - Scalable Vector Graphics [.svg]
94.svm - StarView Metafile [.svm]
95.swf - Macromedia Flash (SWF) [.swf]
96.sxd - OpenOffice.org 1.0 Drawing [.sxd]
97.sxd3 - StarDraw 3.0 [.sxd]
98.sxd5 - StarDraw 5.0 [.sxd]
99.tiff - Tagged Image File Format [.tiff]
100.vor - StarDraw 5.0 Template [.vor]
101.vor3 - StarDraw 3.0 Template [.vor]
102.wmf - Windows Metafile [.wmf]
103.xhtml - XHTML [.xhtml]
104.xpm - X PixMap [.xpm]
105.演示文稿:
106.
107.bmp - Windows Bitmap [.bmp]
108.emf - Enhanced Metafile [.emf]
109.eps - Encapsulated PostScript [.eps]
110.gif - Graphics Interchange Format [.gif]
111.html - HTML Document (OpenOffice.org Impress) [.html]
112.jpg - Joint Photographic Experts Group [.jpg]
113.met - OS/2 Metafile [.met]
114.odd - OpenDocument Drawing (Impress) [.odd]
115.odg - OpenOffice.org 1.0 Drawing (OpenOffice.org Impress) [.odg]
116.odp - OpenDocument Presentation [.odp]
117.otp - OpenDocument Presentation Template [.otp]
118.pbm - Portable Bitmap [.pbm]
119.pct - Mac Pict [.pct]
120.pdf - Portable Document Format [.pdf]
121.pgm - Portable Graymap [.pgm]
122.png - Portable Network Graphic [.png]
123.pot - Microsoft PowerPoint 97/2000/XP Template [.pot]
124.ppm - Portable Pixelmap [.ppm]
125.ppt - Microsoft PowerPoint 97/2000/XP [.ppt]
126.pwp - PlaceWare [.pwp]
127.ras - Sun Raster Image [.ras]
128.sda - StarDraw 5.0 (OpenOffice.org Impress) [.sda]
129.sdd - StarImpress 5.0 [.sdd]
130.sdd3 - StarDraw 3.0 (OpenOffice.org Impress) [.sdd]
131.sdd4 - StarImpress 4.0 [.sdd]
132.sti - OpenOffice.org 1.0 Presentation Template [.sti]
133.stp - OpenDocument Presentation Template [.stp]
134.svg - Scalable Vector Graphics [.svg]
135.svm - StarView Metafile [.svm]
136.swf - Macromedia Flash (SWF) [.swf]
137.sxi - OpenOffice.org 1.0 Presentation [.sxi]
138.tiff - Tagged Image File Format [.tiff]
139.vor - StarImpress 5.0 Template [.vor]
140.vor3 - StarDraw 3.0 Template (OpenOffice.org Impress) [.vor]
141.vor4 - StarImpress 4.0 Template [.vor]
142.vor5 - StarDraw 5.0 Template (OpenOffice.org Impress) [.vor]
143.wmf - Windows Metafile [.wmf]
144.xhtml - XHTML [.xml]
145.xpm - X PixMap [.xpm]
146.電子表格:
147.
148.csv - Text CSV [.csv]
149.dbf - dBase [.dbf]
150.dif - Data Interchange Format [.dif]
151.html - HTML Document (OpenOffice.org Calc) [.html]
152.ods - Open Document Spreadsheet [.ods]
153.ooxml - Microsoft Excel 2003 XML [.xml]
154.pdf - Portable Document Format [.pdf]
155.pts - OpenDocument Spreadsheet Template [.pts]
156.pxl - Pocket Excel [.pxl]
157.sdc - StarCalc 5.0 [.sdc]
158.sdc4 - StarCalc 4.0 [.sdc]
159.sdc3 - StarCalc 3.0 [.sdc]
160.slk - SYLK [.slk]
161.stc - OpenOffice.org 1.0 Spreadsheet Template [.stc]
162.sxc - OpenOffice.org 1.0 Spreadsheet [.sxc]
163.vor3 - StarCalc 3.0 Template [.vor]
164.vor4 - StarCalc 4.0 Template [.vor]
165.vor - StarCalc 5.0 Template [.vor]
166.xhtml - XHTML [.xhtml]
167.xls - Microsoft Excel 97/2000/XP [.xls]
168.xls5 - Microsoft Excel 5.0 [.xls]
169.xls95 - Microsoft Excel 95 [.xls]
170.xlt - Microsoft Excel 97/2000/XP Template [.xlt]
171.xlt5 - Microsoft Excel 5.0 Template [.xlt]
172.xlt95 - Microsoft Excel 95 Template [.xlt]
173.相關資料
174.1.↑ http://dag.wieers.com/home-made/unoconv/
175.
176.轉自:http://www.linux-wiki.cn/index.php/%E6%96%87%E6%A1%A3%E6%A0%BC%E5%BC%8F%E6%89%B9%E9%87%8F%E8%BD%AC%E6%8D%A2(doc,txt,pdf%E7%AD%89)#.E5.8D.95.E4.B8.AA.E6.96.87.E4.BB.B6.E8.BD.AC.E6.8D.A2
177.
178.
179.本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/antony1029/archive/2010/04/30/5547767.aspx
2010-07-30 11:01

此頁由Linux Wiki用戶Chenxing於2008年3月11日 (星期二) 10:45的最後更改。
出自Linux Wiki
在Linux中常常涉及到多種文檔格式,如doc、txt、html、rtf等等。爲了方便文件傳遞,就可能需要在各種格式之間進行轉換。 OpenOffice.Org可以方便的打開多各文檔格式並按需進行轉換,但要一次處理大量文件或要編寫腳本進行轉換時,僅用OpenOffice就難以勝任了。

unoconv利用OpenOffice.Org的UNO接口實現了命令行文檔格式轉換功能,支持所有OpenOffice支持的文件格式,爲文檔的批量轉換提供了可能。

目錄
[隱藏]
•1 下載及安裝
•2 使用方法
◦2.1 單個文件轉換
◦2.2 批量轉換
•3 其它功能簡介
◦3.1 支持的文件格式
◦3.2 服務器/客戶端模式
•4 附:支持的輸出文件格式
•5 相關資料

下載及安裝
目前Debian的源已經有unoconv,如果你使用的發行版還沒有unoconv,可以到它的主頁下載: http://dag.wieers.com/home-made/unoconv/ 。

注意:
該軟件依賴於OpenOffice.Org。
使用方法
單個文件轉換
舉一個例子:要轉換一個doc文件爲PDF格式,只需在命令中執行:

$ unoconv -f pdf myDoc.doc
即會生成一個名爲myDoc.pdf的pdf文件。

批量轉換
批量轉換需要結合find命令或腳本使用,使用時需注意最好使用C/S模式以加快速度:

unoconv --listener &
unoconv -f pdf some-document.odt
unoconv -f doc other-document.odt
unoconv -f jpg some-image.png
unoconv -f xsl some-spreadsheet.csv
其它功能簡介
支持的文件格式
可以執行unoconv --show查看截止到2008年3月11日,unoconv支持以下幾種導出格式(見本文末尾)[1]

服務器/客戶端模式
此模式使文檔的集中處理成爲可能。

附:支持的輸出文件格式
bib - BibTeX [.bib]
doc - Microsoft Word 97/2000/XP [.doc]
doc6 - Microsoft Word 6.0 [.doc]
doc95 - Microsoft Word 95 [.doc]
docbook - DocBook [.xml]
html - HTML Document (OpenOffice.org Writer) [.html]
odt - Open Document Text [.odt]
ott - Open Document Text [.ott]
ooxml - Microsoft Office Open XML [.xml]
pdb - AportisDoc (Palm) [.pdb]
pdf - Portable Document Format [.pdf]
psw - Pocket Word [.psw]
rtf - Rich Text Format [.rtf]
latex - LaTeX 2e [.ltx]
sdw - StarWriter 5.0 [.sdw]
sdw4 - StarWriter 4.0 [.sdw]
sdw3 - StarWriter 3.0 [.sdw]
stw - Open Office.org 1.0 Text Document Template [.stw]
sxw - Open Office.org 1.0 Text Document [.sxw]
text - Text Encoded [.txt]
txt - Plain Text [.txt]
vor - StarWriter 5.0 Template [.vor]
vor4 - StarWriter 4.0 Template [.vor]
vor3 - StarWriter 3.0 Template [.vor]
xhtml - XHTML Document [.html]
圖形格式:

bmp - Windows Bitmap [.bmp]
emf - Enhanced Metafile [.emf]
eps - Encapsulated PostScript [.eps]
gif - Graphics Interchange Format [.gif]
html - HTML Document (OpenOffice.org Draw) [.html]
jpg - Joint Photographic Experts Group [.jpg]
met - OS/2 Metafile [.met]
odd - OpenDocument Drawing [.odd]
otg - OpenDocument Drawing Template [.otg]
pbm - Portable Bitmap [.pbm]
pct - Mac Pict [.pct]
pdf - Portable Document Format [.pdf]
pgm - Portable Graymap [.pgm]
png - Portable Network Graphic [.png]
ppm - Portable Pixelmap [.ppm]
ras - Sun Raster Image [.ras]
std - OpenOffice.org 1.0 Drawing Template [.std]
svg - Scalable Vector Graphics [.svg]
svm - StarView Metafile [.svm]
swf - Macromedia Flash (SWF) [.swf]
sxd - OpenOffice.org 1.0 Drawing [.sxd]
sxd3 - StarDraw 3.0 [.sxd]
sxd5 - StarDraw 5.0 [.sxd]
tiff - Tagged Image File Format [.tiff]
vor - StarDraw 5.0 Template [.vor]
vor3 - StarDraw 3.0 Template [.vor]
wmf - Windows Metafile [.wmf]
xhtml - XHTML [.xhtml]
xpm - X PixMap [.xpm]
演示文稿:

bmp - Windows Bitmap [.bmp]
emf - Enhanced Metafile [.emf]
eps - Encapsulated PostScript [.eps]
gif - Graphics Interchange Format [.gif]
html - HTML Document (OpenOffice.org Impress) [.html]
jpg - Joint Photographic Experts Group [.jpg]
met - OS/2 Metafile [.met]
odd - OpenDocument Drawing (Impress) [.odd]
odg - OpenOffice.org 1.0 Drawing (OpenOffice.org Impress) [.odg]
odp - OpenDocument Presentation [.odp]
otp - OpenDocument Presentation Template [.otp]
pbm - Portable Bitmap [.pbm]
pct - Mac Pict [.pct]
pdf - Portable Document Format [.pdf]
pgm - Portable Graymap [.pgm]
png - Portable Network Graphic [.png]
pot - Microsoft PowerPoint 97/2000/XP Template [.pot]
ppm - Portable Pixelmap [.ppm]
ppt - Microsoft PowerPoint 97/2000/XP [.ppt]
pwp - PlaceWare [.pwp]
ras - Sun Raster Image [.ras]
sda - StarDraw 5.0 (OpenOffice.org Impress) [.sda]
sdd - StarImpress 5.0 [.sdd]
sdd3 - StarDraw 3.0 (OpenOffice.org Impress) [.sdd]
sdd4 - StarImpress 4.0 [.sdd]
sti - OpenOffice.org 1.0 Presentation Template [.sti]
stp - OpenDocument Presentation Template [.stp]
svg - Scalable Vector Graphics [.svg]
svm - StarView Metafile [.svm]
swf - Macromedia Flash (SWF) [.swf]
sxi - OpenOffice.org 1.0 Presentation [.sxi]
tiff - Tagged Image File Format [.tiff]
vor - StarImpress 5.0 Template [.vor]
vor3 - StarDraw 3.0 Template (OpenOffice.org Impress) [.vor]
vor4 - StarImpress 4.0 Template [.vor]
vor5 - StarDraw 5.0 Template (OpenOffice.org Impress) [.vor]
wmf - Windows Metafile [.wmf]
xhtml - XHTML [.xml]
xpm - X PixMap [.xpm]
電子表格:

csv - Text CSV [.csv]
dbf - dBase [.dbf]
dif - Data Interchange Format [.dif]
html - HTML Document (OpenOffice.org Calc) [.html]
ods - Open Document Spreadsheet [.ods]
ooxml - Microsoft Excel 2003 XML [.xml]
pdf - Portable Document Format [.pdf]
pts - OpenDocument Spreadsheet Template [.pts]
pxl - Pocket Excel [.pxl]
sdc - StarCalc 5.0 [.sdc]
sdc4 - StarCalc 4.0 [.sdc]
sdc3 - StarCalc 3.0 [.sdc]
slk - SYLK [.slk]
stc - OpenOffice.org 1.0 Spreadsheet Template [.stc]
sxc - OpenOffice.org 1.0 Spreadsheet [.sxc]
vor3 - StarCalc 3.0 Template [.vor]
vor4 - StarCalc 4.0 Template [.vor]
vor - StarCalc 5.0 Template [.vor]
xhtml - XHTML [.xhtml]
xls - Microsoft Excel 97/2000/XP [.xls]
xls5 - Microsoft Excel 5.0 [.xls]
xls95 - Microsoft Excel 95 [.xls]
xlt - Microsoft Excel 97/2000/XP Template [.xlt]
xlt5 - Microsoft Excel 5.0 Template [.xlt]
xlt95 - Microsoft Excel 95 Template [.xlt]
相關資料
1.↑ http://dag.wieers.com/home-made/unoconv/

轉自:http://www.linux-wiki.cn/index.php/%E6%96%87%E6%A1%A3%E6%A0%BC%E5%BC%8F%E6%89%B9%E9%87%8F%E8%BD%AC%E6%8D%A2(doc,txt,pdf%E7%AD%89)#.E5.8D.95.E4.B8.AA.E6.96.87.E4.BB.B6.E8.BD.AC.E6.8D.A2


本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/antony1029/archive/2010/04/30/5547767.aspx


官方網站: http://www.artofsolving.com/opensource/jodconverter

下載地點:
  http://www.artofsolving.com/opensource/jodconverter
  http://zh.openoffice.org/new/zh_tw/downloads.html
  目前版本: JODConverter v2.2.1, OpenOffice v3.0.0
  使用需求: JDK1.4以上, 安裝OpenOffice v2.0.3以上


  基本簡介:
  JODConverter主要的功能是用來做各種檔案的轉換. 目前測試過, Word,Excel,PowerPoint轉PDF都是沒問題的.
  因爲JODConverter是透過OpenOffice來做轉換, 所以使用前需要先安裝OpenOffice, 並且將OpenOffice的Service啓動, 纔可以使用.


OpenOffice.org具有一個鮮爲人知的特性就是其能夠作爲一個服務來運行,而這種能力具有一定的妙用。舉例來說,你可以把openoffice.og變成一個轉換引擎,利用這種轉換引擎你可以通過網絡接口或命令行工具對文件的格式進行轉換,JODConverter可以幫助你實現OpenOffice.org的這種文件轉換功能。

爲了將OpenOffice.org作爲一個轉換引擎,你必須以服務的方式將它啓動,使它在某個特定的端口監聽連接,在Linux平臺你可以用如下的命令啓動openoffice.org:
soffice -headless -accept=”socket,port=8100;urp;”(我在linux下使用soffice -headless -accept=”socket,host=127.0.0.1,port=8100;urp;”,open office server是開啓來了,但是文件轉換不成功,異常是連接失敗,這個很可以是你用jodconverter來轉換時使用的是localhost,而當你的機有host配置文件裏沒有將localhost與127.0.0.1對應起來時,就無法解析了,這裏可以修改host文件或去掉host=127.0.0.1,這樣我試過可以成功)

在Windows平臺, 使用如下命令:
“C:\Program Files\OpenOffice.org 2.2\program\soffice” -accept=”socket,port=8100;urp;”

  使用教學:
  Step1: 安裝OpenOffice
  Step2: 啓動OpenOffice Service




1 cd C:\Program Files\OpenOffice.org 3\program

  2 soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

  Step3:將JODConverter的Jar檔放進專案中的Library, 請檢查你的專案是否包含以下的Jar檔:

  jodconverter-2.2.1.jar
  jurt-2.3.0.jar
  xstream-1.2.2.jar
  ridl-2.3.0.jar
  commons-io-1.3.1.jar
  juh-2.3.0.jar
  slf4j-api-1.4.3.jar
  unoil-2.3.0.jar
  slf4j-jdk14-1.4.3.jar

  Step4: 準備一個word檔放在c:/document.rtf
  Step5: 執行以下程式


Java代碼 01.<span style="font-size: medium;">import java.io.File;
02.
03.  import com.artofsolving.jodconverter.DocumentConverter;
04.
05.  import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
06.
07.  import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
08.
09.  import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
10.
11.  public class JodDemo {
12.
13.  public static void main(String[] args) throws Exception{
14.
15.  File inputFile = new File("c:/document.rtf");
16.
17.  File outputFile = new File("c:/document.doc");
18.
19.  // connect to an OpenOffice.org instance running on port 8100
20.
21.  OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
22.
23.  connection.connect();
24.
25.  // convert
26.
27.  DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
28.
29.  converter.convert(inputFile, outputFile);
30.
31.  // close the connection
32.
33.  connection.disconnect();
34.
35.  }
36.
37.  } </span>
程式說明:


  程式的部份相當簡潔, 特別要注意的地方是第12行連線的port必須與你啓動OpenOffice的Port相同,
  另外JODConverter預設是用副檔名作文件種類的判斷, 所以副檔名必須要正確才行.
  如果副檔名比較特別的話, 就必須在convert()的時候強制指定Document Type.

心得:
  JODConverter使用起來相當方便, 官網也提供War檔讓JODConverter變成Web Service提供給不同的語言來呼叫.
  特別要注意的是, OpenOffice Service並不是ThreadSafe的, 多個Web AP在使用的時候必須要注意.


那我也來補充一些好了
之前也在試這個檔案轉換的程式
程式最好加上 try-catch
因為之前發現有些檔案 format 不能轉,發生 Exception 後,connection 不會自動切斷,程序會hand 住
所以改成如下方式:


Java代碼 01.<span style="font-size: medium;">public void convert(String input, String output){
02. File inputFile = new File(input);
03. File outputFile = new File(output);
04. OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
05. try {
06. connection.connect();
07. DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
08. converter.convert(inputFile, outputFile);
09. } catch(Exception e) {
10. e.printStackTrace();
11. } finally {
12. try{ if(connection != null){connection.disconnect(); connection = null;}}catch(Exception e){}
13. }
14. } </span>


再來,明明就是 open office 的檔案,卻生不能轉換的問題。例如:*.STW, *.SXD, *.ODF 等,後來才知道可以自行指定來源檔和輸出檔的 mime-type,程式如下:


Java代碼 01.<span style="font-size: medium;">public void convertSTW(String input, String output){
02. DocumentFormat stw = new DocumentFormat("OpenOffice.org 1.0 Template", DocumentFamily.TEXT, "application/vnd.sun.xml.writer", "stw");
03. DefaultDocumentFormatRegistry formatReg = new DefaultDocumentFormatRegistry();
04. DocumentFormat pdf = formatReg.getFormatByFileExtension("pdf");
05. File inputFile = new File(input);
06. File outputFile = new File(output);
07. OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
08. try {
09. connection.connect();
10. DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
11. converter.convert(inputFile, stw, outputFile, pdf);
12. } catch(Exception e) {
13. e.printStackTrace();
14. } finally {
15. try{ if(connection != null){connection.disconnect(); connection = null;}}catch(Exception e){}
16. }
17. } </span>
上面的程式是轉換 STW 到 PDF,如果是 SXD / ODF 則只需要變更 DocumentFormat 的內容即可。


Java代碼 01.<span style="font-size: medium;">DocumentFormat sxd = new DocumentFormat("OpenOffice.org 1.0 Drawing", DocumentFamily.DRAWING, "application/vnd.sun.xml.sraw", "sxd");
02.
03.DocumentFormat odf = new DocumentFormat("OpenDocument Math", DocumentFamily.TEXT, "application/vnd.oasis.opendocument.formula", "odf"); </span>
所有 default support 的 DocumentFormat 都在 com.artofsolving.jodconverter.DefaultDocumentFormatRegistry 裡,但並非所有 open office 支援的 file format 都有,所以要像上面的方法自行去定義 DocumentFormat,至於它裏面的參數可以從jodconverter-2.2.2.jar包的com.artofsolving.jodconverter包下的document-formats.xml文件裏面得到,這樣就可以完成多種格式的轉換,如open office,ms office , wps office及所有的純文本文件。
發佈了38 篇原創文章 · 獲贊 1 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章