package cn.wise.sc.cement.business.util;


import cn.hutool.core.io.file.FileReader;
import cn.wise.sc.cement.business.util.dfs.FastDFSUtils;
import com.aspose.cells.SaveFormat;
import com.aspose.cells.Workbook;
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("D:\\JavaProject\\tianjin-cement\\cement-business\\src\\main\\resources\\检测报告模板(最新).xls");
            Workbook document = new Workbook(new FileInputStream(file));
            //pdf路径
            File outputFile = new File("temp-" + System.currentTimeMillis() + ".pdf");
            //操作文档保存
            document.save(outputFile.getAbsolutePath(), 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();
        }
    }
}
