package com.example.client.service;
|
|
import org.springframework.stereotype.Service;
|
|
@Service
|
public class PPTToPdfService {/*
|
public static boolean getLicense() {
|
boolean result = false;
|
try {
|
InputStream is = new FileInputStream("C:\\Users\\admin\\Desktop\\file_manage\\lib\\license.xml");
|
License aposeLic = new License();
|
aposeLic.setLicense(is);
|
result = true;
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
public void PPTToPdf(String filePath,String outputFilePath) {
|
if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
|
return;
|
}
|
// 输入和输出文件路径
|
|
try (InputStream inputStream = new FileInputStream(filePath);
|
OutputStream outputStream = new FileOutputStream(outputFilePath)) {
|
// 加载 PowerPoint 文件
|
Presentation presentation = new Presentation(inputStream);
|
|
// 创建 PDF 保存选项
|
PdfOptions pdfOptions = new PdfOptions();
|
|
// 将 PowerPoint 文件保存为 PDF
|
presentation.save(outputStream, com.aspose.slides.SaveFormat.Pdf);
|
|
System.out.println("PowerPoint 文件成功转换为 PDF 文件!");
|
} catch (Exception e) {
|
System.out.println("转换过程中出现错误: " + e.getMessage());
|
e.printStackTrace();
|
}
|
}*/
|
}
|