本文整理汇总了Java中com.artofsolving.jodconverter.DocumentConverter类的典型用法代码示例。如果您正苦于以下问题:Java DocumentConverter类的具体用法?Java DocumentConverter怎么用?Java DocumentConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentConverter类属于com.artofsolving.jodconverter包,在下文中一共展示了DocumentConverter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convert
import com.artofsolving.jodconverter.DocumentConverter; //导入依赖的package包/类
/**
* 将word文档转换成html文档
*
* @param docFile
* 需要转换的word文档
* @param filepath
* 转换之后html的存放路径
* @return 转换之后的html文件
*/
public static File convert(File docFile, String filepath) {
// 创建保存html的文件
File htmlFile = new File(filepath + "/" + new Date().getTime()
+ ".html");
// 创建Openoffice连接
OpenOfficeConnection con = new SocketOpenOfficeConnection(8100);
try {
// 连接
con.connect();
System.out.println("获取OpenOffice连接成功...");
} catch (ConnectException e) {
System.out.println("获取OpenOffice连接失败...");
e.printStackTrace();
}
// 创建转换器
DocumentConverter converter = new OpenOfficeDocumentConverter(con);
// 转换文档问html
converter.convert(docFile, htmlFile);
// 关闭openoffice连接
con.disconnect();
return htmlFile;
}
开发者ID:huanzhou,项目名称:jeecms6,代码行数:32,代码来源:Doc2Html.java
示例2: convertFile
import com.artofsolving.jodconverter.DocumentConverter; //导入依赖的package包/类
/**
* 转换文件.
*/
private String convertFile(File fromFile, File toFile, DocumentConverter converter, JTextArea resultTextArea,
boolean filesDealAsTxt) {
try {
if (filesDealAsTxt) {
File copyToFile = new File(toFile.getAbsolutePath() + ".convert-as-txt-tmp.txt");
CopyFileFromCommonsIo.copyFile(fromFile, copyToFile);
converter.convert(copyToFile, toFile);
copyToFile.delete();
} else {
converter.convert(fromFile, toFile);
}
return "Success";
} catch (Exception e) {
GuiUtils.log(e);
return "Fail[Exception: " + e.getMessage() + "]";
}
}
开发者ID:baishui2004,项目名称:common_gui_tools,代码行数:21,代码来源:JODConverterVisual.java
示例3: getDocumentConverter
import com.artofsolving.jodconverter.DocumentConverter; //导入依赖的package包/类
private DocumentConverter getDocumentConverter() {
initOpenOfficeConnection();
return documentConverter;
}
开发者ID:GovernIB,项目名称:helium,代码行数:5,代码来源:ArxiuConvertirView.java
示例4: convert
import com.artofsolving.jodconverter.DocumentConverter; //导入依赖的package包/类
private void convert(
final InputStream in,
final DocumentFormat inputFormat,
final OutputStream out,
final DocumentFormat outputFormat) throws Exception {
final String host = getPropertyHost();
final int port = getPropertyPort();
final OpenOfficeConnection connection = new SocketOpenOfficeConnection(host, port);
ExecutorService executor = Executors.newSingleThreadExecutor();
try {
Future<String> future = executor.submit(new Callable<String>() {
@Override
public String call() throws Exception {
connection.connect();
DocumentConverter converter = new StreamOpenOfficeDocumentConverter(
connection,
getDocumentFormatRegistry());
converter.convert(
in,
inputFormat,
out,
outputFormat);
return "Ok";
}
});
if (getPropertyTimeout() != -1)
future.get(getPropertyTimeout(), TimeUnit.SECONDS);
else
future.get();
} catch (TimeoutException e) {
throw new SistemaExternTimeoutException(
null,
null,
null,
null,
null,
null,
null,
null,
null,
"(Conversió OpenOffice)",
e);
} finally {
if (connection.isConnected())
connection.disconnect();
}
executor.shutdownNow();
}
开发者ID:GovernIB,项目名称:helium,代码行数:49,代码来源:OpenOfficeUtils.java
示例5: main
import com.artofsolving.jodconverter.DocumentConverter; //导入依赖的package包/类
/**
* @param args
* @throws ConnectException
*/
public static void main(String[] args) throws ConnectException {
//
File inputFile = new File("C:\\Users\\KYJ\\Desktop\\convert\\memojava.doc");
File outputFile = new File("C:\\Users\\KYJ\\Desktop\\convert\\memojav2.html");
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection, new CustomDocFormatRegistry());
converter.convert(inputFile, outputFile);
// close the connection
connection.disconnect();
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:25,代码来源:ConverterSampleTest.java
示例6: docToPdf
import com.artofsolving.jodconverter.DocumentConverter; //导入依赖的package包/类
/**
*
* @return
* @throws ConnectException
*/
public boolean docToPdf(HttpServletRequest request) throws ConnectException {
Date start = new Date();
/*//打开端口
String path = request.getSession()
.getServletContext().getRealPath("/WEB-INF/classes/OpenOffice_Service.bat");
path = path.replaceFirst(" ", "\" \"");
System.out.println(path);
try {
Process pro = Runtime.getRuntime().exec("d:\\1.bat");
StreamGobbler errorGobbler = new StreamGobbler(pro.getErrorStream(), "Error");
StreamGobbler outputGobbler = new StreamGobbler(pro.getInputStream(), "Iutput");
errorGobbler.start();
outputGobbler.start();
pro.getOutputStream().close();
try {
pro.waitFor();
pro.destroy();
pro.exitValue();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}*/
// connect to an OpenOffice.org instance running on port 8100
//Process pro = Runtime.getRuntime().e
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
} catch (ConnectException cex) {
if (connection.isConnected()) {
connection.disconnect();
connection = null;
}
throw cex;
} catch(IllegalArgumentException e){
throw new IllegalArgumentException("文件类型错误!上传文档格式不要高于office2003");
}
if (connection != null) {
connection.disconnect();
connection = null;
}
long l = (start.getTime() - new Date().getTime());
long day = l / (24 * 60 * 60 * 1000);
long hour = (l / (60 * 60 * 1000) - day * 24);
long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
System.out.println("生成" + outputFile.getName() + "耗费:" + min + "分" + s
+ "秒");
return true;
}
开发者ID:imalexyang,项目名称:ExamStack,代码行数:71,代码来源:JOD4DocToPDF.java
注:本文中的com.artofsolving.jodconverter.DocumentConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论