当前位置: 首页>>代码示例>>Java>>正文


Java OpenOfficeDocumentConverter类代码示例

本文整理汇总了Java中com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter的典型用法代码示例。如果您正苦于以下问题:Java OpenOfficeDocumentConverter类的具体用法?Java OpenOfficeDocumentConverter怎么用?Java OpenOfficeDocumentConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OpenOfficeDocumentConverter类属于com.artofsolving.jodconverter.openoffice.converter包,在下文中一共展示了OpenOfficeDocumentConverter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; //导入依赖的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: main

import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; //导入依赖的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

示例3: docToPdf

import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; //导入依赖的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.openoffice.converter.OpenOfficeDocumentConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。