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
|
public class WordUtil {
public static void wordToPdf(InputStream inputStream, File pdfFile) throws Exception{ if (getLicense()) { OutputStream outputStream = new FileOutputStream(pdfFile);
Document document = new Document(inputStream); document.save(outputStream, SaveFormat.PDF); } else { throw new Exception("license文件验证失败!"); } }
private static boolean getLicense() { try { File file = new File("./src/main/java/util/aspose_words/license.xml"); InputStream is = new FileInputStream(file); License aposeLic = new License(); aposeLic.setLicense(is); return true; } catch (Exception e) { e.printStackTrace(); return false; } } }
|