org.artofsolving.jodconverter.office.OfficeManager Java Examples

The following examples show how to use org.artofsolving.jodconverter.office.OfficeManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseTests.java    From kbase-doc with Apache License 2.0 8 votes vote down vote up
protected void convert(File inputFile, File outputFile){
		DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
		configuration.setPortNumber(8100);
		configuration.setOfficeHome(new File(libreOfficeDirPath));
//		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();
        }
	}
 
Example #2
Source File: BaseTests.java    From kbase-doc with Apache License 2.0 6 votes vote down vote up
protected void convert(File inputFile, File outputFile, String password){
		DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
		configuration.setPortNumber(8100);
		configuration.setOfficeHome(new File(libreOfficeDirPath));
//		configuration.setOfficeHome(new File("D:/Program Files/OpenOffice"));

		OfficeManager officeManager = configuration.buildOfficeManager();
        officeManager.start();
        DocumentFormatRegistry formatRegistry = new DefaultDocumentFormatRegistry();
        OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager, formatRegistry);
        Map<String,?> defaultLoadProperties = createDefaultLoadProperties(password);
        converter.setDefaultLoadProperties(defaultLoadProperties);
        try {
        	 converter.convert(inputFile, outputFile);
        } catch (Exception e){
        	e.printStackTrace();
		} finally {
            officeManager.stop();
        }
	}
 
Example #3
Source File: ConvertTests.java    From kbase-doc with Apache License 2.0 6 votes vote down vote up
@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();
        }
	}
 
Example #4
Source File: ContextListener.java    From csustRepo with MIT License 5 votes vote down vote up
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);
	}
 
Example #5
Source File: ViewOfficeTools.java    From csustRepo with MIT License 5 votes vote down vote up
public OfficeManager getOfficeManager() {
	if(officeManager==null){
		officeManager=newOfficeManager();
	    getOfficeManager().start();
	}
	
	return officeManager;
}
 
Example #6
Source File: ViewOfficeTools.java    From csustRepo with MIT License 5 votes vote down vote up
public synchronized OfficeManager newOfficeManager() {
	String officehome=ServletActionContext.getServletContext().getInitParameter("officehome");
	int portnumbers=Integer.parseInt(ServletActionContext.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小时
	
	return configuration.buildOfficeManager();
}
 
Example #7
Source File: OfficeDocumentConverter.java    From kkFileView with Apache License 2.0 4 votes vote down vote up
public OfficeDocumentConverter(OfficeManager officeManager) {
    this(officeManager, new DefaultDocumentFormatRegistry());
}
 
Example #8
Source File: ViewOfficeTools.java    From csustRepo with MIT License 4 votes vote down vote up
public void setOfficeManager(OfficeManager officeManager) {
	this.officeManager = officeManager;
}
 
Example #9
Source File: OfficeConService.java    From wenku with MIT License 4 votes vote down vote up
public OfficeManager getOfficeManager() {
    return officeManager;
}
 
Example #10
Source File: OfficeDocumentConverter.java    From wenku with MIT License 4 votes vote down vote up
public OfficeDocumentConverter(OfficeManager officeManager, DocumentFormatRegistry formatRegistry) {
    this.officeManager = officeManager;
    this.formatRegistry = formatRegistry;
}
 
Example #11
Source File: OfficeDocumentConverter.java    From wenku with MIT License 4 votes vote down vote up
public OfficeDocumentConverter(OfficeManager officeManager) {
    this(officeManager, new DefaultDocumentFormatRegistry());
}
 
Example #12
Source File: DocConverter.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Obtain OpenOffice Manager
 */
public OfficeManager getOfficeManager() {
	return officeManager;
}
 
Example #13
Source File: OfficeDocumentConverter.java    From kkFileView with Apache License 2.0 4 votes vote down vote up
public OfficeDocumentConverter(OfficeManager officeManager, DocumentFormatRegistry formatRegistry) {
    this.officeManager = officeManager;
    this.formatRegistry = formatRegistry;
}
 
Example #14
Source File: OfficeDocumentConverter.java    From kkFileViewOfficeEdit with Apache License 2.0 4 votes vote down vote up
public OfficeDocumentConverter(OfficeManager officeManager) {
    this(officeManager, new DefaultDocumentFormatRegistry());
}
 
Example #15
Source File: JodConverterSharedInstance.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public OfficeManager getOfficeManager()
{
    return officeManager;
}
 
Example #16
Source File: CommonDocumentConverter.java    From sun-wordtable-read with Apache License 2.0 4 votes vote down vote up
public CommonDocumentConverter(OfficeManager officeManager, String inputFile, String outputFile, boolean needDeleteInputFile) {
	this.officeManager = officeManager;
	this.inputFile = inputFile;
	this.outputFile = outputFile;
	this.needDeleteInputFile = needDeleteInputFile;
}
 
Example #17
Source File: TxtDocumentConverter.java    From sun-wordtable-read with Apache License 2.0 4 votes vote down vote up
public TxtDocumentConverter(OfficeManager officeManager, String inputFile, String outputFile, boolean needDeleteInputFile) {
	super(officeManager, inputFile, outputFile, needDeleteInputFile);
}
 
Example #18
Source File: WebappContext.java    From kbase-doc with Apache License 2.0 4 votes vote down vote up
public OfficeManager getOfficeManager() {
    return officeManager;
}
 
Example #19
Source File: OfficeDocumentConverter.java    From kkFileViewOfficeEdit with Apache License 2.0 4 votes vote down vote up
public OfficeDocumentConverter(OfficeManager officeManager, DocumentFormatRegistry formatRegistry) {
    this.officeManager = officeManager;
    this.formatRegistry = formatRegistry;
}
 
Example #20
Source File: JodConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Gets the JodConverter OfficeManager.
 * @return
 */
public abstract OfficeManager getOfficeManager();