Closed Ritian-Zhang closed 5 years ago
核心转换时调用jodconverter,targetFile 后缀以.pdf结尾,转换后的目标文件就是 pdf 格式
protected void convert(File originFile, File targetFile) {
WebappContext webappContext = WebappContext.get(servletContext);
OfficeDocumentConverter converter = webappContext.getDocumentConverter();
try {
long startTime = System.currentTimeMillis();
converter.convert(originFile, targetFile);
long conversionTime = System.currentTimeMillis() - startTime;
log.info(String.format("successful conversion: %s [%db] to %s in %dms", FilenameUtils.getExtension(originFile.getName()), originFile.length(), FilenameUtils.getExtension(targetFile.getName()), conversionTime));
} catch (Exception e) {
e.printStackTrace();
log.error(String.format("failed conversion: %s [%db] to %s; %s; input file: %s", FilenameUtils.getExtension(originFile.getName()), originFile.length(), FilenameUtils.getExtension(targetFile.getName()), e, targetFile.getName()));
}
}
有木有word转pdf的