org.artofsolving.jodconverter.document.DocumentFormatRegistry Java Examples

The following examples show how to use org.artofsolving.jodconverter.document.DocumentFormatRegistry. 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: ConvertTests.java    From kbase-doc with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetFormatByExtension(){
	DocumentFormatRegistry formatRegistry = new DefaultDocumentFormatRegistry();
	DocumentFormat formatByExtension = formatRegistry.getFormatByExtension("docx");
	System.out.println(formatByExtension.getName());
	Map<DocumentFamily, Map<String, ?>> storePropertiesByFamily = formatByExtension.getStorePropertiesByFamily();
	System.out.println(storePropertiesByFamily.size());
	
}
 
Example #5
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 #6
Source File: OfficeDocumentConverter.java    From kkFileViewOfficeEdit with Apache License 2.0 4 votes vote down vote up
public DocumentFormatRegistry getFormatRegistry() {
    return formatRegistry;
}
 
Example #7
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 #8
Source File: OfficeDocumentConverter.java    From kkFileView with Apache License 2.0 4 votes vote down vote up
public DocumentFormatRegistry getFormatRegistry() {
    return formatRegistry;
}
 
Example #9
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 #10
Source File: OfficeDocumentConverter.java    From wenku with MIT License 4 votes vote down vote up
public DocumentFormatRegistry getFormatRegistry() {
    return formatRegistry;
}