jinlin
2025-04-28 efce7ce3e63712ecc8b4c3039a73b508fc3ea880
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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();
        }
    }*/
}