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. Hadoop(四)C#连接Hive

    Hive Hive将HiveQL(类sql语言)转为MapReduce,完成数据的查询与分析,减少了编写MapReduce的复杂度.它有以下优点: 学习成本低:熟悉sql就能使用 良好的数据分析:底层 ...

  2. 痞子衡嵌入式:大话双核i.MXRT1170之在线联合调试双核工程的三种方法(IAR篇)

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家分享的是i.MXRT1170下在线联合调试双核工程的方法(基于IAR). 前段时间痞子衡写过一篇<双核i.MXRT1170之单独在线调试从 ...

  3. svelte组件:svelte3.x自定义美化虚拟滚动条组件svelte-scrollbar

    基于svelte3.0自定义pc端虚拟滚动条组件svelteScrollbar. svelte-scrollbar:运用svelte3.x创建的桌面pc版自定义美化滚动条组件.支持是否原生滚动条.自动 ...

  4. UDP协议、操作系统、同步与异步、阻塞与非阻塞

    UDP协议 # 客户端 import socket server = socket.socket(type=socket.SOCK_DGRAM) server.bind(('127.0.0.1', 8 ...

  5. Springcloud及Git线上配置详解

    SpringCloud 这个阶段该如何学? 三层架构 + MVC 框架: Spring IOC AOP SpringBoot,新一代的JavaEE开发标准,自动装配 模块化~ all in one,代 ...

  6. brew常用命令

    Homebrew 常用命令 brew -help # 查看帮助命令 brew config # 查看配置信息 brew list # 查看已安装软件包列表 brew cleanup # 清理所有包的旧 ...

  7. 好客租房27-state的基本使用

    5.1state的基本使用 状态:数据 是组件内部的私有数据 只能再组件内部使用 state的值是对象 表示一个组件中可以有多个数据 获取数据 this.state //导入react     imp ...

  8. QTP——功能测试

    一.前言(课设目的及内容) QTP是quicktest Professional的简称,是一种自动测试工具.使用QTP的目的是想用它来执行重复的手动测试,主要是用于回归测试和测试同一软件的新版本.因此 ...

  9. 联盟链 Hyperledger Fabric 应用场景

    一.说明 本文主要通过一个例子分享以 Hyperledger Fabric 为代表的联盟链应用场景. 关于 Fabric 的相关概念请先参考文章 <Hyperledger Fabric 核心概念 ...

  10. python面向对象(封装、多态、反射)

    目录 面向对象之封装 @property 面向对象之多态 面向对象之反射 面向对象之封装 含义 将类中的某些名字按照特殊的书写方式"隐藏"起来,不让外界直接调用,目的是为了不然外界 ...