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


Java OfficeManager.start方法代码示例

本文整理汇总了Java中org.artofsolving.jodconverter.office.OfficeManager.start方法的典型用法代码示例。如果您正苦于以下问题:Java OfficeManager.start方法的具体用法?Java OfficeManager.start怎么用?Java OfficeManager.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.artofsolving.jodconverter.office.OfficeManager的用法示例。


在下文中一共展示了OfficeManager.start方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConvert

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的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();
        }
	}
 
开发者ID:ekoz,项目名称:kbase-doc,代码行数:26,代码来源:ConverteTests.java

示例2: convert

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的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();
        }
	}
 
开发者ID:ekoz,项目名称:kbase-doc,代码行数:20,代码来源:ConverteTests.java

示例3: main

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的package包/类
public static void main(String[] args) {

		// 1) Start LibreOffice in headless mode.
		OfficeManager officeManager = null;
		try {
			officeManager = new DefaultOfficeManagerConfiguration()
					.setOfficeHome(new File("C:/Program Files/LibreOffice 3.5"))
					.buildOfficeManager();
			officeManager.start();

			// 2) Create JODConverter converter
			OfficeDocumentConverter converter = new OfficeDocumentConverter(
					officeManager);

			// 3) Create PDF
			createPDF(converter);
			createPDF(converter);

		} finally {
			// 4) Stop LibreOffice in headless mode.
			if (officeManager != null) {
				officeManager.stop();
			}
		}
	}
 
开发者ID:xxsafin,项目名称:DocToHtml,代码行数:26,代码来源:Docx4j_GettingStartedToPDF.java

示例4: main

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的package包/类
public static void main(String[] args) {

		// 1) Start LibreOffice in headless mode.
		OfficeManager officeManager = null;
		try {
			officeManager = new DefaultOfficeManagerConfiguration()
					.setOfficeHome(new File(Params.officeHome))
					.buildOfficeManager();
			officeManager.start();

			// 2) Create JODConverter converter
			OfficeDocumentConverter converter = new OfficeDocumentConverter(
					officeManager);

			// 3) Create HTML
			createHTML(converter);
			createHTML(converter);

		} finally {
			// 4) Stop LibreOffice in headless mode.
			if (officeManager != null) {
				officeManager.stop();
			}
		}
	}
 
开发者ID:xxsafin,项目名称:DocToHtml,代码行数:26,代码来源:Docx4j_GettingStartedToHTML.java

示例5: createOfficeManager

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的package包/类
public static void createOfficeManager(String officePath, Consumer<OfficeManager> consumer) {
	OfficeManager manager = null;
	try {
		DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
		if (!Strings.isEmpty(officePath)) {
			configuration.setOfficeHome(officePath);
		}
		manager = configuration.buildOfficeManager();
		manager.start();
		if (consumer != null) {
			consumer.accept(manager);
		}
	} finally {
		if (manager != null) {
			manager.stop();
		}
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:19,代码来源:DocumentConverter.java

示例6: office2pdf

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的package包/类
/** 
 * 将Office文档转换为PDF. 需要安装OpenOffice
 *  
 * @param inputFilePath 
 *            源文件,绝对路径. 可以是Office2003-2007全部格式的文档, 包括.doc, .docx, .xls, .xlsx, .ppt, .pptx等. 
 *  
 * @param outputFilePath 
 *            目标文件.绝对路径. 
 */
public static void office2pdf(String inputFilePath, String outputFilePath) {
	DefaultOfficeManagerConfiguration config = new DefaultOfficeManagerConfiguration();

	String officeHome = getOfficeHome();
	//设置OpenOffice.org安装目录
	config.setOfficeHome(officeHome);
	//设置转换端口,默认为8100
	//config.setPortNumbers(8100);  
	//设置任务执行超时为60分钟
	config.setTaskExecutionTimeout(1000 * 60 * 60L);
	//设置任务队列超时为24小时
	config.setTaskQueueTimeout(1000 * 60 * 60 * 24L);
	OfficeManager officeManager = config.buildOfficeManager();
	officeManager.start();
	System.out.println("office转换服务启动成功!");
	OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager);
	File inputFile = new File(inputFilePath);
	if (inputFile.exists()) {// 找不到源文件, 则返回  
		File outputFile = new File(outputFilePath);
		if (!outputFile.getParentFile().exists()) { // 假如目标路径不存在, 则新建该路径  
			outputFile.getParentFile().mkdirs();
		}
		converter.convert(inputFile, outputFile);

	}
	if (null != officeManager) {
		officeManager.stop();
		System.out.println("office转换服务完成。");
	}
}
 
开发者ID:pecker,项目名称:kony-converter,代码行数:40,代码来源:OfficeToPdf.java

示例7: startOManager

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的package包/类
private synchronized OfficeManager startOManager() throws Exception
{
	String officeHome = EnvironmentConfig.getOpenOfficeHomePath();
	if (officeHome == null || officeHome.trim().equals(""))
		throw new Exception("OpenOfficeHomePath EnvironmentConfig must be set!");
	
	OfficeManager officeManager = null;    	
	long start = 0;
	long end = 0;
	int port = getAvaiblePort();
						
	officeManager = new DefaultOfficeManagerConfiguration()
		.setOfficeHome(officeHome)	 
		.setConnectionProtocol(OfficeConnectionProtocol.SOCKET)
		.setPortNumber(port)	 					
		.setTaskExecutionTimeout(taskExecutionTimeout)
		.setMaxTasksPerProcess(maxTasksPerProcess)	 				
		.buildOfficeManager();
	
	System.out.println("OfficeHome : " + officeHome);										
	start = System.currentTimeMillis();
	
	/**************************************************************/
	try {
		officeManager.start();				
	}
	catch (Exception exception) {
		throw new Exception("OfficeManager start failed: ", exception);
	} 			
	/**************************************************************/
	
	end = System.currentTimeMillis();				
	System.out.println("Starting time : " + (new Float(end-start))/1000 + " seconds");
	
	return officeManager;
}
 
开发者ID:oopcell,项目名称:AvoinApotti,代码行数:37,代码来源:ConversionHelper.java

示例8: initViewOfficeTools

import org.artofsolving.jodconverter.office.OfficeManager; //导入方法依赖的package包/类
private void initViewOfficeTools(ServletContextEvent sce){

		String officehome=sce.getServletContext().getInitParameter("officehome");
		int portnumbers=Integer.parseInt(sce.getServletContext().getInitParameter("portnumbers"));

		DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
		configuration.setOfficeHome(officehome);//设置OpenOffice.org安装目录
		configuration.setPortNumbers(portnumbers); //设置转换端口,默认为8100
		configuration.setTaskExecutionTimeout(1000 * 60 * 10L);//设置任务执行超时为5分钟
		configuration.setTaskQueueTimeout(1000 * 60 * 60 * 24L);//设置任务队列超时为24小时

		OfficeManager officeManager=configuration.buildOfficeManager();
		officeManager.start();
		ViewOfficeTools.newInstance().setOfficeManager(officeManager);
	}
 
开发者ID:binghuo365,项目名称:csustRepo,代码行数:16,代码来源:ContextListener.java


注:本文中的org.artofsolving.jodconverter.office.OfficeManager.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。