| | |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 芯导软件(江苏)有限公司 |
| | | * @author |
| | | * @since 2024-11-08 11:08:11 |
| | | */ |
| | | @Service |
| | |
| | | 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; |
| | | } |
| | | } |