javadoc转换docx_使⽤Java将DOC⽂件转换为DOCX JODConvertor通过⽹络协议调⽤OpenOffice / LibreOffice . 因此,它可以“在OpenOffice中执⾏任何操作” . 这包括转换格式 . 但它只能像您运⾏的任何OpenOffice版本⼀样出⾊ . 我的⼀个⽂档中有⼀些艺术,并没有像我希望的那样转换它们 .
根据v3的⾕歌代码⽹站,不再⽀持JODConvertor .
要让JOD完成这项⼯作,你需要做⼀些事情
private static void transformBinaryWordDocToDocX(File in, File out)
{
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
DocumentFormat docx = FormatRegistry().getFormatByExtension("docx");
docx.setStoreProperties(DocumentFamily.TEXT,
Collections.singletonMap("FilterName", "MS Word 2007 XML"));
}
private static void transformBinaryWordDocToW2003Xml(File in, File out)transform和convert的区别
{
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);;
DocumentFormat w2003xml = new DocumentFormat("Microsoft Word 2003 XML", "xml", "text/xml");
w2003xml.setInputFamily(DocumentFamily.TEXT);
w2003xml.setStoreProperties(DocumentFamily.TEXT, Collections.singletonMap("FilterName", "MS Word 2003 XML"));
}
private static OfficeManager officeManager;
@BeforeClass
public static void setupStatic() throws IOException {
/*officeManager = new DefaultOfficeManagerConfiguration()
.setOfficeHome("C:/Program Files/LibreOffice 3.6")
.buildOfficeManager();
*/
officeManager = new
ExternalOfficeManagerConfiguration().setConnectOnStart(true).setPortNumber(8100).buildOfficeManager();
officeManager.start();
}
@AfterClass
public static void shutdownStatic() throws IOException {
officeManager.stop();
}
为此,你需要将LibreOffice作为⽹络服务器运⾏(我⽆法让JODConvertor的'按需运⾏'部分在具有LO 3.6的Windows下⼯作)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论