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


Java DocumentFormat类代码示例

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


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

示例1: OpenOfficePrintingService

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public OpenOfficePrintingService(String host, int port, String outputFormat) {
    Preconditions.checkNotNull(host, "Invalid host.");
    Preconditions.checkArgument(!host.isEmpty(), "Invalid host.");
    Preconditions.checkArgument(port >= 0, "Invalid port.");
    Preconditions.checkArgument(port <= 65535, "Invalid port.");
    Preconditions.checkNotNull(outputFormat, "Invalid output format.");
    DocumentFormat format = new DefaultDocumentFormatRegistry().getFormatByFileExtension(outputFormat);
    Preconditions.checkArgument(format != null, "Unknown output format.");

    this.connection = new SocketOpenOfficeConnection(host, port);
    try {
        connection.connect();
        connection.disconnect();
    } catch (Exception e) {
        throw new RuntimeException(host + ":" + port + " service not available.", e);
    }

    this.host = host;
    this.port = port;
    this.outputFormat = format;
}
 
开发者ID:FenixEdu,项目名称:oddjet,代码行数:22,代码来源:OpenOfficePrintingService.java

示例2: convert

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
private void convert(
		InputStream in,
		DocumentFormat inputFormat,
		OutputStream out,
		DocumentFormat outputFormat) {
	getDocumentConverter().convert(
			in,
			inputFormat,
			out,
			outputFormat);
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:12,代码来源:ArxiuConvertirView.java

示例3: formatPerNomArxiu

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
private DocumentFormat formatPerNomArxiu(String fileName) {
	int indexPunt = fileName.lastIndexOf(".");
	if (indexPunt != -1) {
		String extensio = fileName.substring(indexPunt + 1);
		return getDocumentFormatRegistry().getFormatByFileExtension(extensio);
	}
	return null;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:9,代码来源:ArxiuConvertirView.java

示例4: nomArxiuConvertit

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
private String nomArxiuConvertit(String fileName, DocumentFormat format) {
	int indexPunt = fileName.lastIndexOf(".");
	if (indexPunt != -1) {
		String nom = fileName.substring(0, indexPunt);
		return nom + "." + format.getFileExtension();
	} else {
		return fileName + "." + format.getFileExtension();
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:10,代码来源:ArxiuConvertirView.java

示例5: convertir

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public void convertir(
		String arxiuNom,
		InputStream arxiuContingut,
		String extensioSortida,
		OutputStream sortida) throws Exception {
	logger.info("Conversió OpenOffice (" +
			"arxiuNom=" + arxiuNom + ", " +
			"arxiuContingut=" + arxiuContingut.available() + "bytes, " +
			"extensioSortida=" + extensioSortida + ")");
	DocumentFormat inputFormat = formatPerNomArxiu(arxiuNom);			
	DocumentFormat outputFormat = getDocumentFormatRegistry().getFormatByFileExtension(extensioSortida);
	if (!outputFormat.getFileExtension().equals(inputFormat.getFileExtension())) {
		convert(
				arxiuContingut,
				inputFormat,
				sortida,
				outputFormat);
	} else {
		byte[] buffer = new byte[1024];
		int len = arxiuContingut.read(buffer);
		while (len >= 0) {
			sortida.write(buffer, 0, len);
			len = arxiuContingut.read(buffer);
		}
		arxiuContingut.close();
		sortida.close();
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:29,代码来源:OpenOfficeUtils.java

示例6: nomArxiuConvertit

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public String nomArxiuConvertit(
		String arxiuNom,
		String extensioSortida) {
	DocumentFormat outputFormat = getDocumentFormatRegistry().getFormatByFileExtension(extensioSortida);
	int indexPunt = arxiuNom.lastIndexOf(".");
	if (indexPunt != -1) {
		String nom = arxiuNom.substring(0, indexPunt);
		return nom + "." + outputFormat.getFileExtension();
	} else {
		return arxiuNom + "." + outputFormat.getFileExtension();
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:13,代码来源:OpenOfficeUtils.java

示例7: getArxiuMimeType

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public String getArxiuMimeType(String nomArxiu) {
	DocumentFormat format = formatPerNomArxiu(nomArxiu);
	if (format == null)
		return new MimetypesFileTypeMap().getContentType(nomArxiu);
	else
		return format.getMimeType();
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:8,代码来源:OpenOfficeUtils.java

示例8: render

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public byte[] render(byte[] contingut, String nom) throws Exception {
	Boolean conversionEnabled = "true".equalsIgnoreCase((String)GlobalProperties.getInstance().get("app.conversio.portasignatures.actiu"));
	boolean conversion = (conversionEnabled == null) ? getPropertyEnabled() : conversionEnabled.booleanValue();
	if (!getPropertyEnabled()) conversion = false;
	ByteArrayInputStream inputStream = new ByteArrayInputStream(contingut);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	if (contingut != null) {
		if (conversion) {
			DocumentFormat inputFormat = formatPerNomArxiu(nom);
			if (inputFormat == null)
				throw new IllegalArgumentException("format d'entrada no suportat");
			DocumentFormatRegistry documentFormatRegistry = getDocumentFormatRegistry();
			DocumentFormat outputFormat = documentFormatRegistry.getFormatByFileExtension(getPropertyOutputExtension().toLowerCase());
			if (outputFormat == null)
				throw new IllegalArgumentException("format de sortida no suportat");
			// No s'afegeix res al pdf.
			if (!outputFormat.getFileExtension().equals(inputFormat.getFileExtension())) {
				convert(
						inputStream,
						inputFormat,
						outputStream,
						outputFormat);
			} else {
				return contingut;
			}
		}
	}
	return outputStream.toByteArray();
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:30,代码来源:ConvertirPDF.java

示例9: nomArxiuConvertit

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
@SuppressWarnings("unused")
private String nomArxiuConvertit(String fileName, DocumentFormat format) {
	int indexPunt = fileName.lastIndexOf(".");
	if (indexPunt != -1) {
		String nom = fileName.substring(0, indexPunt);
		return nom + "." + format.getFileExtension();
	} else {
		return fileName + "." + format.getFileExtension();
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:11,代码来源:ConvertirPDF.java

示例10: CustomDocFormatRegistry

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public CustomDocFormatRegistry() {

		final DocumentFormat doc = new DocumentFormat("Microsoft Word", DocumentFamily.TEXT, "application/msword", "docx");
		doc.setExportFilter(DocumentFamily.TEXT, "MS Word 2007");
		addDocumentFormat(doc);

		final DocumentFormat xlsx = new DocumentFormat("Microsoft Excel", DocumentFamily.SPREADSHEET, "application/vnd.ms-excel", "xlsx");
		xlsx.setExportFilter(DocumentFamily.SPREADSHEET, "MS Excel 2007");
		addDocumentFormat(xlsx);

		final DocumentFormat pptx = new DocumentFormat("Microsoft PowerPoint", DocumentFamily.PRESENTATION,
				"application/vnd.ms-powerpoint", "pptx");
		pptx.setExportFilter(DocumentFamily.PRESENTATION, "MS PowerPoint 2007");
		addDocumentFormat(pptx);
	}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:16,代码来源:CustomDocFormatRegistry.java

示例11: convert

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

示例12: getArxiuMimeType

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public String getArxiuMimeType(String nomArxiu) {
	DocumentFormat format = formatPerNomArxiu(nomArxiu);
	return format.getMimeType();
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:5,代码来源:ConvertirPDF.java

示例13: getOutputFormat

import com.artofsolving.jodconverter.DocumentFormat; //导入依赖的package包/类
public DocumentFormat getOutputFormat() {
    return outputFormat;
}
 
开发者ID:FenixEdu,项目名称:oddjet,代码行数:4,代码来源:OpenOfficePrintingService.java


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