本文整理汇总了Java中org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration.setPortNumber方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultOfficeManagerConfiguration.setPortNumber方法的具体用法?Java DefaultOfficeManagerConfiguration.setPortNumber怎么用?Java DefaultOfficeManagerConfiguration.setPortNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration
的用法示例。
在下文中一共展示了DefaultOfficeManagerConfiguration.setPortNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testConvert
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration; //导入方法依赖的package包/类
@Test
public void testConvert() throws IOException {
// File inputFile = new File("D:/Workspace/kbase-doc/target/classes/static/DATAS/1512561737109/1.doc");
File inputFile = new File("D:/Workspace/kbase-doc/target/classes/static/DATAS/1512561737109/1512561737109.html");
File outputFile = new File("D:/Workspace/kbase-doc/target/classes/static/DATAS/1512561737109/" + Calendar.getInstance().getTimeInMillis() + ".docx");
// if (!outputFile.exists()){
// outputFile.createNewFile();
// }
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
configuration.setPortNumber(8100);
configuration.setOfficeHome(new File("D:/Program Files/LibreOffice"));
OfficeManager officeManager = configuration.buildOfficeManager();
officeManager.start();
DocumentFormatRegistry formatRegistry = new DefaultDocumentFormatRegistry();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager, formatRegistry);
try {
converter.convert(inputFile, outputFile);
} catch (Exception e){
e.printStackTrace();
} finally {
officeManager.stop();
}
}
示例2: convert
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration; //导入方法依赖的package包/类
private void convert(File inputFile, File outputFile){
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
configuration.setPortNumber(8100);
configuration.setOfficeHome(new File("D:/Program Files/LibreOffice"));
// configuration.setOfficeHome(new File("D:/Program Files/OpenOffice"));
OfficeManager officeManager = configuration.buildOfficeManager();
officeManager.start();
DocumentFormatRegistry formatRegistry = new DefaultDocumentFormatRegistry();
OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager, formatRegistry);
try {
converter.convert(inputFile, outputFile);
} catch (Exception e){
e.printStackTrace();
} finally {
officeManager.stop();
}
}
示例3: OfficeConService
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration; //导入方法依赖的package包/类
/**
*
* 创建一个新的实例 OfficeConService.
*/
public OfficeConService() {
DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
//设置转换端口,默认为2002
if (StringUtils.isNotBlank(this.officePort)) {
configuration.setPortNumber(Integer.parseInt(this.officePort));
logger.info("office转换服务监听端口设置为:" + this.officePort);
}
//设置office安装目录
if (StringUtils.isNotBlank(officeHome)) {
configuration.setOfficeHome(new File(this.officeHome));
logger.info("设置office安装目录为:" + this.officeHome);
}
officeManager = configuration.buildOfficeManager();
documentConverter = new OfficeDocumentConverter(this.officeManager);
}