public static long pptToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getPptLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
File pdfFile = new File(outFile);
FileOutputStream os = new FileOutputStream(pdfFile);
Presentation pres = new Presentation(inFile);
pres.save(os, com.aspose.slides.SaveFormat.Pdf);
os.close();
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return pdfFile.length();
} catch (Exception e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}
复制代码
6.pdf转ppt:
public static long pdfToPpt(String inFile, String outFile) {
if (!com.yrnet.transfer.business.transfer.file.License.getPdfLicense()) {
return 0;
}
long old = System.currentTimeMillis();
Document pdfDocument = new Document(inFile);
PptxSaveOptions pptxOptions = new PptxSaveOptions();
pptxOptions.setExtractOcrSublayerOnly(true);
pdfDocument.save(outFile, pptxOptions);
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return new File(outFile).length();
}
复制代码
7.odt转pdf:
public static long odtToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getWordLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
Document doc = new Document(inFile);
doc.save(outFile);
long fileSize = new File(outFile).length();
long now = System.currentTimeMillis();
log.info("target file size:{}",fileSize);
Out.print(inFile, outFile, now, old);
return fileSize;
} catch (Exception e) {
log.error(inFile + "转换失败,请重试",e);
throw new Exception(e.getMessage());
}
}
复制代码
8.pdf转图片:
[code]public static long pdfToPng(String inFile, List outFile) throws Exception { long size = 0; if (!com.yrnet.transfer.business.transfer.file.License.getPdfLicense()) { return size; } try { long old = System.currentTimeMillis(); Document pdfDocument = new Document(inFile); Resolution resolution = new Resolution(960); JpegDevice jpegDevice = new JpegDevice(resolution); for (int index=1;index