Explorar o código

aspose 破解

lyhzzz %!s(int64=2) %!d(string=hai) anos
pai
achega
c0756342ed
Modificáronse 2 ficheiros con 46 adicións e 12 borrados
  1. 8 2
      pom.xml
  2. 38 10
      src/main/java/com/fdkankan/sale/util/pdf/TestForExcel2PDF.java

+ 8 - 2
pom.xml

@@ -189,10 +189,16 @@
 
         <dependency>
             <groupId>com.aspose</groupId>
-            <artifactId>aspose-cells</artifactId>
-            <version>22.7</version>
+            <artifactId>aspose-cells-fk</artifactId>
+            <version>20.7</version>
         </dependency>
 
+        <!--
+                mvn deploy:deploy-file -Dfile=D:\sale\aspose-cells-20.7-fk.jar
+                    -DgroupId=com.aspose -DartifactId=aspose-cells-fk -Dversion=20.7 -Dpackaging=jar
+                    -Durl=http://192.168.0.115:8081/nexus-2.14.2-01/content/repositories/releases/ -DrepositoryId=releases
+        -->
+
         <dependency>
             <groupId>org.sejda.imageio</groupId>
             <artifactId>webp-imageio</artifactId>

+ 38 - 10
src/main/java/com/fdkankan/sale/util/pdf/TestForExcel2PDF.java

@@ -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");
+    }
+
 }