Aspose for Java最新版文档转换使用
Aspose简介
Aspose.Total是Aspose公司旗下全套文件格式处理解决方案,提供最完整、最高效的文档处理解决方案集,无需任何其他软件安装和依赖。主要提供.net、java、C++d三个开发语言的工具包,通过它,可以对办公文档格式的转换和文档内容的在线编辑,如:Word, Excel, PowerPoint, PPT,图片,PDF等文档。 另外,Aspose.Total 还提供了用于写邮件、拼写检查、创建条形码、OCR和3D等等。
使用样例(22.3版本)
以下列举几种常用的文档格式转换样例,对于Aspose.Total来说,这几个功能只是它的冰山一角。
1.excel转pdf:
public static long excelToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getExcelLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
File pdfFile = new File(outFile);
Workbook wb = new Workbook(inFile);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);
FileOutputStream fileOS = new FileOutputStream(pdfFile);
wb.save(fileOS, SaveFormat.PDF);
fileOS.close();
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return pdfFile.length();
}catch (Exception e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}


