java 破解aspose.words 18.6 使用

发布于:2025-05-09 ⋅ 阅读:(14) ⋅ 点赞:(0)

资源包:https://download.csdn.net/download/qq_36598111/90787167

jar包是破解过的,直接可以使用。

引入jar,要引入本地的,不要直接引入仓库的

<dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>18.6</version>
        </dependency>

然后把license.xml 放在resourseces下面

直接使用就可以,注意要先验证之后才能转换


import java.io.*;

import com.aspose.words.*;


public class DocToPdf {
	public static boolean getLicense() {
		boolean result = false;
		try {
			InputStream is = DocToPdf.class.getClassLoader()
					.getResourceAsStream("license.xml"); // license.xml应放在..\WebRoot\WEB-INF\classes路径下
			License aposeLic = new License();
			aposeLic.setLicense(is);
			result = true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public static void doc2pdf(String Address, String outPath) {

		if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
			return;
		}
		try {
			long old = System.currentTimeMillis();
			File file = new File(outPath); // 新建一个空白pdf文档
			FileOutputStream os = new FileOutputStream(file);
			Document doc = new Document(Address); // Address是将要被转化的word文档
			doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML,
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		doc2pdf("D:/123.doc", "D:/1234.pdf");
	}

}


网站公告

今日签到

点亮在社区的每一天
去签到