yang_shj
11 months ago
30 changed files with 408 additions and 161 deletions
@ -0,0 +1,53 @@
|
||||
package com.hnac.hzims.safeproduct.utils; |
||||
|
||||
import cn.hutool.system.SystemUtil; |
||||
import com.aspose.words.Document; |
||||
import com.aspose.words.FontSettings; |
||||
import com.aspose.words.License; |
||||
import com.aspose.words.SaveFormat; |
||||
import lombok.SneakyThrows; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileOutputStream; |
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class AsposeUtil { |
||||
|
||||
/** |
||||
* 加载license 用于破解 不生成水印 |
||||
* |
||||
* @author LCheng |
||||
* @date 2020/12/25 13:51 |
||||
*/ |
||||
@SneakyThrows |
||||
private static void getLicense() { |
||||
try (InputStream is = AsposeUtil.class.getClassLoader().getResourceAsStream("License.xml")) { |
||||
License license = new License(); |
||||
license.setLicense(is); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* word转pdf |
||||
* |
||||
* @param wordPath word文件保存的路径 |
||||
* @param pdfPath 转换后pdf文件保存的路径 |
||||
* @author LCheng |
||||
* @date 2020/12/25 13:51 |
||||
*/ |
||||
@SneakyThrows |
||||
public static void wordToPdf(String wordPath, String pdfPath) { |
||||
getLicense(); |
||||
File file = new File(pdfPath); |
||||
try (FileOutputStream os = new FileOutputStream(file)) { |
||||
if(SystemUtil.getOsInfo().isLinux()) { |
||||
FontSettings.setFontsFolder("/usr/share/fonts/chinese", true); |
||||
} |
||||
Document doc = new Document(wordPath); |
||||
doc.save(os, SaveFormat.PDF); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
<License> |
||||
<Data> |
||||
<Products> |
||||
<Product>Aspose.Total for Java</Product> |
||||
<Product>Aspose.Words for Java</Product> |
||||
</Products> |
||||
<EditionType>Enterprise</EditionType> |
||||
<SubscriptionExpiry>20991231</SubscriptionExpiry> |
||||
<LicenseExpiry>20991231</LicenseExpiry> |
||||
<SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber> |
||||
</Data> |
||||
<Signature> |
||||
sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU= |
||||
</Signature> |
||||
</License> |
Binary file not shown.
Loading…
Reference in new issue