|
@@ -10,6 +10,11 @@ import com.itextpdf.text.pdf.parser.ImageRenderInfo;
|
|
|
import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
|
|
|
import com.itextpdf.text.pdf.parser.RenderListener;
|
|
|
import com.itextpdf.text.pdf.parser.TextRenderInfo;
|
|
|
+import javassist.CannotCompileException;
|
|
|
+import javassist.ClassPool;
|
|
|
+import javassist.CtClass;
|
|
|
+import javassist.CtMethod;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
@@ -92,17 +97,15 @@ public class TestForExcel2PDF {
|
|
|
* 获取license 去除水印
|
|
|
* @return
|
|
|
*/
|
|
|
- public static boolean getLicense() {
|
|
|
- boolean result = false;
|
|
|
+ public static void getLicense() {
|
|
|
try {
|
|
|
-// InputStream is = TestForExcel2PDF.class.getClassLoader().getResourceAsStream("\\license.xml");
|
|
|
-// License aposeLic = new License();
|
|
|
-// aposeLic.setLicense(is);
|
|
|
- result = true;
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("/com.aspose.cells.lic_2999.xml");
|
|
|
+ InputStream license = classPathResource.getInputStream();
|
|
|
+ License aposeLic = new License();
|
|
|
+ aposeLic.setLicense(license);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -112,9 +115,7 @@ public class TestForExcel2PDF {
|
|
|
* @param desFilePathd pad 输出文件目录
|
|
|
*/
|
|
|
public static void excel2pdf(String sourceFilePath, String desFilePathd ){
|
|
|
- if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
|
|
|
- return;
|
|
|
- }
|
|
|
+ getLicense();
|
|
|
try {
|
|
|
Workbook wb = new Workbook(sourceFilePath);// 原始excel路径
|
|
|
// IndividualFontConfigs configs = new IndividualFontConfigs();
|
|
@@ -178,6 +179,33 @@ public class TestForExcel2PDF {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static void crackAspose(String JarPath, String outPath) throws Exception {
|
|
|
+ // 这个是得到反编译的池
|
|
|
+ ClassPool pool = ClassPool.getDefault();
|
|
|
+
|
|
|
+ // 取得需要反编译的jar文件,设定路径
|
|
|
+ pool.insertClassPath(JarPath);
|
|
|
+
|
|
|
+ CtClass cc_License = pool.get("com.aspose.cells.License");
|
|
|
+
|
|
|
+ CtMethod method_isLicenseSet = cc_License.getDeclaredMethod("isLicenseSet");
|
|
|
+ method_isLicenseSet.setBody("return true;");
|
|
|
+
|
|
|
+ CtClass cc_License2 = pool.get("com.aspose.cells.License");
|
|
|
+ CtMethod method_setLicense = cc_License2.getDeclaredMethod("setLicense");
|
|
|
+ method_setLicense.setBody("{ a = new com.aspose.cells.License();\n" +
|
|
|
+ " com.aspose.cells.zbiw.a();}");
|
|
|
+
|
|
|
+ CtMethod method_k = cc_License.getDeclaredMethod("k");
|
|
|
+ method_k.setBody("return new java.util.Date(Long.MAX_VALUE);");
|
|
|
+
|
|
|
+ cc_License.writeFile(outPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception{
|
|
|
+ crackAspose("D:\\sale\\aspose-cells-20.7.jar","D:\\sale");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|