package cn.wise.sc.energy.power.plant.business.utils;


import cn.hutool.core.io.file.FileReader;
import cn.wise.sc.energy.power.plant.business.utils.dfs.FastDFSUtils;
import com.aspose.words.Document;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;


/**
 * @author neo.shu
 * @since 2020/9/10 20:38
 */

public class Word2PdfUtil {


    public static void main(String[] args) {
        try {
            long time = System.currentTimeMillis();
            File file = new File("C:\\Users\\admin\\Desktop\\发电机远程智能监测与诊断系统设计方案(舒立冬).docx");
            Document document = new Document(new FileInputStream(file));
            //pdf路径
            File outputFile = new File("temp-" + System.currentTimeMillis() + ".pdf");
            //操作文档保存
            document.save(outputFile.getAbsolutePath(), com.aspose.words.SaveFormat.PDF);
            FileReader fileReader = new FileReader(outputFile.getAbsolutePath());
            String filePath = FastDFSUtils.uploadPic(fileReader.readBytes(), outputFile.getName(), file.length());
            long time1 = System.currentTimeMillis();
            System.out.println((time1 - time) / 1000);
            System.out.println(filePath);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
