Aspose简介

Aspose.Total是Aspose公司旗下全套文件格式处理解决方案,提供最完整、最高效的文档处理解决方案集,无需任何其他软件安装和依赖。主要提供.net、java、C++d三个开发语言的工具包,通过它,可以对办公文档格式的转换和文档内容的在线编辑,如:Word, Excel, PowerPoint, PPT,图片,PDF等文档。 另外,Aspose.Total 还提供了用于写邮件、拼写检查、创建条形码、OCR和3D等等。

使用样例(22.3版本)

以下列举几种常用的文档格式转换样例,对于Aspose.Total来说,这几个功能只是它的冰山一角。

1.excel转pdf:

public static long excelToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getExcelLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
File pdfFile = new File(outFile);
Workbook wb = new Workbook(inFile);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);
FileOutputStream fileOS = new FileOutputStream(pdfFile);
wb.save(fileOS, SaveFormat.PDF);
fileOS.close();
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return pdfFile.length();
}catch (Exception e) {
e.printStackTrace();
throw new Exception(e.getMessage());
} }

2.pdf转excel:

public static long pdfToExcel(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getPdfLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
Document doc = new Document(inFile);
ExcelSaveOptions options = new ExcelSaveOptions();
options.setFormat(ExcelSaveOptions.ExcelFormat.XLSX);
doc.save(outFile, options);
Out.print(inFile, outFile, System.currentTimeMillis(), old);
return new File(outFile).length();
}catch (Exception e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}

3.word转pdf:

public static long wordToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getWordLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
File file = new File(outFile);
FileOutputStream os = new FileOutputStream(file);
Document doc = new Document(inFile);
Document tmp = new Document();
tmp.removeAllChildren();
tmp.appendDocument(doc, ImportFormatMode.USE_DESTINATION_STYLES);
System.out.println("开始解析word文档" + inFile);
doc.save(os, SaveFormat.PDF);
long now = System.currentTimeMillis();
log.info("target file size:{}",file.length());
os.close();
Out.print(inFile, outFile, now, old);
return file.length();
} catch (Exception e) {
log.error(inFile + "转换失败,请重试",e);
throw new Exception(e.getMessage());
}
}

4.pdf转word:

public static long pdfToDoc(String inFile, String outFile) {
if (!com.yrnet.transfer.business.transfer.file.License.getPdfLicense()) {
return 0;
}
log.info("开始转换...");
long old = System.currentTimeMillis();
Document pdfDocument = new Document(inFile);
DocSaveOptions saveOptions = new DocSaveOptions();
/** 或者DocSaveOptions.DocFormat.DocX*/
saveOptions.setFormat(DocSaveOptions.DocFormat.Doc);
pdfDocument.save(outFile, saveOptions);
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
log.info("转换结束...");
return new File(outFile).length();
}

5.ppt转pdf:

public static long pptToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getPptLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
File pdfFile = new File(outFile);
FileOutputStream os = new FileOutputStream(pdfFile);
Presentation pres = new Presentation(inFile);
pres.save(os, com.aspose.slides.SaveFormat.Pdf);
os.close();
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return pdfFile.length();
} catch (Exception e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}

6.pdf转ppt:

public static long pdfToPpt(String inFile, String outFile) {
if (!com.yrnet.transfer.business.transfer.file.License.getPdfLicense()) {
return 0;
}
long old = System.currentTimeMillis();
Document pdfDocument = new Document(inFile);
PptxSaveOptions pptxOptions = new PptxSaveOptions();
pptxOptions.setExtractOcrSublayerOnly(true);
pdfDocument.save(outFile, pptxOptions);
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return new File(outFile).length();
}

7.odt转pdf:

public static long odtToPdf(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getWordLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
Document doc = new Document(inFile);
doc.save(outFile);
long fileSize = new File(outFile).length();
long now = System.currentTimeMillis();
log.info("target file size:{}",fileSize);
Out.print(inFile, outFile, now, old);
return fileSize;
} catch (Exception e) {
log.error(inFile + "转换失败,请重试",e);
throw new Exception(e.getMessage());
}
}

8.pdf转图片:

public static long pdfToPng(String inFile, List<String> outFile) throws Exception {
long size = 0;
if (!com.yrnet.transfer.business.transfer.file.License.getPdfLicense()) {
return size;
}
try {
long old = System.currentTimeMillis();
Document pdfDocument = new Document(inFile);
Resolution resolution = new Resolution(960);
JpegDevice jpegDevice = new JpegDevice(resolution);
for (int index=1;index<=pdfDocument.getPages().size();index++) {
String path = inFile.substring(0,inFile.lastIndexOf(".")) + "_"+index+".png";
File file = new File(path);
size += file.length();
FileOutputStream fileOs = new FileOutputStream(file);
jpegDevice.process(pdfDocument.getPages().get_Item(index), fileOs);
outFile.add(path);
fileOs.close();
long now = System.currentTimeMillis();
Out.print(inFile, path, now, old);
}
return size;
}catch (Exception e){
log.error(e.getMessage(),e);
throw new Exception(e.getMessage());
}
}

9.excel转图片:

public static long excelToPic(String inFile, String outFile) throws Exception {
if (!com.yrnet.transfer.business.transfer.file.License.getExcelLicense()) {
return 0;
}
try {
long old = System.currentTimeMillis();
Workbook wb = new Workbook(inFile);
Worksheet sheet = wb.getWorksheets().get(0);
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setImageFormat(ImageFormat.getPng());
imgOptions.setCellAutoFit(true);
imgOptions.setOnePagePerSheet(true);
SheetRender render = new SheetRender(sheet, imgOptions);
render.toImage(0, outFile);
long now = System.currentTimeMillis();
Out.print(inFile, outFile, now, old);
return new File(outFile).length();
}catch (Exception e) {
e.printStackTrace();
throw new Exception(e.getMessage());
}
}

10. ...

为什么要破解

官方提供免费的试用,转换出来是带有水印和次数限制的。所以想要绕过许可的困扰。只有两个办法:购买和破解。

从官方的更新频率来看,基本上一个月左右一个版本,所说官方比较重视并重点投入这个项目,同时也说明软件存在待优化的bug。其实在21版本之前有很多转换上的兼容问题,如:

布局错位、特殊符号无法识别,表格内容错乱等造成转换后文档阅读障碍。对于内容要求搞的使用场景来说,无法使用在生产上。

以上主要对最新的22版本进行破解(笔者破解的时候官方发布最新的是22.3版本)

破解方法

  • 破解思路:每个工具包都有对应的License类,这个类是检验许可和授权的入口。从该类入手,慢慢研究反编译后的源码,但其实它使用了混淆手断,使得反编译后的代码看起来比较吃力。

即使如此,对于破解并不是干扰太大,我们不需要去弄清楚每一行,甚至每个方法的功能。破解的任务是移除校验授权对应的代码块或方法。

最简单也是最有效的办法就是直接删除,在这里羚羊就不一一带入分析源码的坑了。下面直接提供现成的包。

  • 破解工具:源码弄不下来,不能像老套路一样,修改对应源码后再对着整个套源码重新编译一遍。怎么办?只能对着目标class文件直接修改保存并覆盖原class文件。在这羚羊推荐三个比较方便使用的工具:

一、JByteMod

这个是界面化工具,修改比较方便,直接把目标jar打开,找到目标的类方法,然后对着要删除的操作指令右键删除保存即可

二、javassist

界面化的JByteMod,虽然小白都可以使用。但有时候你删除不对,甚至从直观上删除操作指令后没有破坏整个class文件,但是却无法使用,比如报方法不存在、class检验异常等。遇到这种情况的时候,使用javassist就灵活,成功率高很多。如:

public void testMod_words1(){
try {
ClassPool.getDefault().insertClassPath("/Users/dengbp/Downloads/doc-sys/pdf-transfer/src/lib/aspose-words-22.3.0-jdk17.jar");
CtClass zzZJJClass = ClassPool.getDefault().getCtClass("com.aspose.words.zzP6");
CtMethod methodB = zzZJJClass.getDeclaredMethod("zzWMy");
methodB.setBody("{return 256;}");
zzZJJClass.writeFile("/Users/dengbp/Downloads/");
} catch (Exception e) {
System.out.println("错误==" + e);
}
}

三、asm

javassist是基于java编程去修改源码内容,而相对于asm,它跟界面化的JByteMod一样,都是直接对jvm的指令去修改。如:

成品贡献(22.3版本)

链接: https://pan.baidu.com/s/13DcNlLsrzlU_1j6pniRGhw  密码: ***

需要jar包,请私聊,V:dbp168

PS:本文仅用于参考学习,请勿用于商业用途

Aspose最新版文档格式转换使用破解的更多相关文章

  1. windwos文档格式转换成unix格式

    在工作学习中我们避免不了需要将一些脚本和命令记录在笔记里面,我使用的是有道云笔记,每当我将上次记录在有道云的脚本复制出来进行使用的时候,总会报一些奇怪的错误,要么是包含换行符,要么就是格式不对,但是我 ...

  2. Java利用jacob实现文档格式转换

    实现文档格式之间的转换,我使用的是jacob-1.7版本,需要jacob.jar来调用activex控件,本机需安装WPS/office,还需要jacob.jar以及jacob.dll 其中:    ...

  3. Python - 文档格式转换(CSV与JSON)

  4. 【好文翻译】一步一步教你使用Spire.Doc转换Word文档格式

    背景: 年11月,微软宣布作为ECMA国际主要合作伙伴,将其开发的基于XML的文件格式标准化,称之为"Office Open XML" .Open XML的引进使office文档结 ...

  5. C#word(2007)操作类--新建文档、添加页眉页脚、设置格式、添加文本和超链接、添加图片、表格处理、文档格式转化

    转:http://www.cnblogs.com/lantionzy/archive/2009/10/23/1588511.html 1.新建Word文档 #region 新建Word文档/// &l ...

  6. 导出WPS office文档格式的说明

     针对microsoft office的文档格式,WPS office分别提供wps对应doc,et对应xls两种格式,word和excel是办公系统使用的普及度最广的文件格式,而国内的政府行政单 ...

  7. 【itext】7步制作兼容各种文档格式的Itext5页眉页脚 实现page x pf y

    itext5页眉页脚工具类,实现page x of y 完美兼容各种格式大小文档A4/B5/B3,兼容各种文档格式自动计算页脚XY轴坐标 鉴于没人做的这么细致,自己就写了一个itext5页眉页脚工具类 ...

  8. Java导出freemarker实现下载word文档格式功能

    首先呢,先说一下制作freemarker模板步骤, 1. 在WPS上写出所要的下载的word格式当做模板 2. 把模板内不固定的内容(例:从数据库读取的信息)写成123或者好代替的文字标注 3. 把固 ...

  9. wordxml文档格式说明

    近期需要对word xml文档进行各种操作,需要熟悉 wordxml 文档格式,搜索了一番后发现 open xml sdk 官网的文档最好.就按照官网说明来记录一番 1 word xml 文档基本格式 ...

随机推荐

  1. Quantexa CDI(场景决策智能)Syneo平台介绍

    Quantexa 大数据服务提供商, 使用实体解析, 关系分析和人工智能技术帮助客户进行数据处理和预防金融犯罪. 企业概览 2016年成立, 当前规模500人 服务特色是场景决策智能CDI(conte ...

  2. 变量命名 函数命名 方法 Naming cheatsheet

    Naming things is hard. This sheet attempts to make it easier. Although these suggestions can be appl ...

  3. 解决:Could not resolve dependencies for project xxx: Could not find artifact xxx

    引言 运行A module,找不到B module的依赖报错.A.B module都在project中. 报错信息 [INFO] Scanning for projects... [INFO] [IN ...

  4. Kubernetes 从入门到进阶实战教程 (2021 最新万字干货版)

    作者:oonamao 毛江云,腾讯 CSIG 应用开发工程师原文:来源腾讯技术工程,https://tinyurl.com/ya3ennxf 写在前面 笔者今年 9 月从端侧开发转到后台开发,第一个系 ...

  5. 用上这个 Mock 神器,让你的开发爽上天!

    ​ 前端的痛苦 作为前端,最痛苦的是什么时候? 每个迭代,需求文档跟设计稿都出来了,静态页面唰唰两天就做完了.可是做前端又不是简单地把后端吐出来的数据放到页 面上就完了,还有各种前端处理逻辑啊. 后端 ...

  6. SpringBoot线程池

    1.遇到的场景 提高一下插入表的性能优化,两张表,先插旧的表,紧接着插新的表,若是一万多条数据就有点慢了 2.使用步骤 用Spring提供的对ThreadPoolExecutor封装的线程池Threa ...

  7. Spring Boot 2.7.0发布,2.5停止维护,节奏太快了吧

    这几天是Spring版本日,很多Spring工件都发布了新版本, Spring Framework 6.0.0 发布了第 4 个里程碑版本,此版本包含所有针对 5.3.20 的修复补丁,以及特定于 6 ...

  8. mysqldump还原备份数据时遇到一个问题

    问题描述 ERROR 1839 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_MODE = O ...

  9. 2020级C++实验课-期末机考模拟考题解

    做这个题解的理由很简单,有很多同学想写但是不会写,凑巧我写了,所以搞个题解. 顺序就是题单里的顺序(界面左上角菜单切换文章,右上角目录方便查看) 1:黑马白马 题意: 随机得到一个数字,如果是偶数,则 ...

  10. 选择器补充与CSS属性

    目录 伪元素选择器 选择器优先级 CSS属性 宽和高 字体样式 文字属性 背景属性 边框属性 display属性 盒子模型 浮动(float) 清除浮动 伪元素选择器 伪元素选择器可以通过CSS操作文 ...