| | |
| | | saveBatch(list); |
| | | } |
| | | |
| | | public String wordToPdf(String wordPath, String pdfPath) { |
| | | FileOutputStream os = null; |
| | | try { |
| | | InputStream is = new ClassPathResource("/lib/license.xml").getInputStream(); |
| | | License license = new License(); |
| | | license.setLicense(is); |
| | | if (!license.getIsLicensed()) { |
| | | System.out.println("License验证不通过..."); |
| | | return null; |
| | | } |
| | | //生成一个空的PDF文件 |
| | | File file = new File(pdfPath.replace(".pdf", ".pdf")); |
| | | os = new FileOutputStream(file); |
| | | //要转换的word文件 |
| | | com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); |
| | | doc.save(os, SaveFormat.PDF); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (os != null) { |
| | | try { |
| | | os.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |