docx4j 是一個開源的(Apache許可證v2)Java函式庫,專門用來創建、編輯和儲存打包 Microsoft Open XML文檔(包括Word docx, Powerpoint pptx和Excel xlsx)。docx4j最初是由Plutext Pty Ltd於2008年創建。docx4j與微軟的OpenXML SDK類似,但是是面向Java的。它使用JAXB在記憶體中創建Java物件。它的功能強大,對於支援的文檔的格式,你可以用docx4j做出你想要的效果。
特色功能
- 打開已存在的docx/pptx/xlsx(從檔案系統, SMB/CIFS, 使用VFS從WebDAV等)
- 創建新的docx文檔
- 用程式來處理docx文檔
- CustomXML綁定(使用OpenDoPE外掛程式來處理重複綁定和條件綁定)
- 將檔儲存成HTML或PDF
- Diff/比較文檔、段落
- 導入二進位文檔(使用Apache POI的HWPF)
- 處理Word 2007的xmlPackage(pkg)格式
- 將docx保存成docx(壓縮格式)或者JCR(未壓縮格式)
- 字體支援(字型替代,使用文檔中嵌入的任何字體)
同時,需花時間理解JAXB和Open XML檔結構。可以使用線上的webapp查看docx/xlsx/pptx的檔結構,或者下載本地的應用Word AddIn來查看docx的檔結構。
docx4j | Docx4j Enterprise Edition | |
100% open source OpenXML in Java, powered by JAXB | ||
docx4j | V | V |
pptx4j | V | V |
xlsx4j | V | V |
Key open source features - processing | ||
content manipulation via JAXB | V | V |
template variable processing | V | V |
docx OpenDoPE conditions/repeats | V | V |
docx MERGEFIELD (mailmerge) processing | V | V |
Key open source features - importing | ||
XML data binding (including images) | V | V |
XHTML to docx | via optional LGPL2 jar | via optional LGPL2 jar |
XHTML altChunk to docx (no need for Word) | via optional LGPL2 jar | via optional LGPL2 jar |
RTF and binary .doc to docx (using Microsoft Word driven by documents4j) | V | V |
Key open source features - export formats | ||
docx to XHTML | V | V |
docx to PDF (3 ways) | V | V |
Licensing | ||
License Type | Open source (Apache v2) | Commercial (source code available) |
Enterprise Edition additional components | ||
docx "MergeDocx" append/concatenate | - | V |
docx altChunk merged as native content (no need for Word) | - | V |
docx: file embedding (OLE) in docx | - | V |
docx: digital signatures | - | V |
pptx "MergePptx" append/concatenate | - | V |
pptx: file embedding (OLE) in pptx | - | V |
pptx: digital signatures | - | V |
xlsx: file embedding (OLE) in xlsx | - | V |
xlsx: digital signatures | - | V |
Support features | ||
community forums, StackOverflow | V | V |
OpenXML documentation | V | V |
super useful code generation (webapp or Word AddIn) | V | V |
dedicated support team | - | V |
proactive technical guidance | - | V |
product roadmap input | - | V |
release fast track | - | V |
docx4j for JAXB 3.0 and Java 11+