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. python3.5上使用virtualenv创建虚拟环境的坑

    一.坑一:安装的virtualenv版本太高 显示使用virtualenv 安装虚拟环境报错 出现这个问题就是说明你的virtualev安装的版本太高,降低一下版本重新安装即可,我这里使用的是15这个 ...

  2. prometheus监控预警之AlertManager邮箱报警

    Alertmanager 主要用于接收 Prometheus 发送的告警信息,它支持丰富的告警通知渠道,例如邮件.微信.钉钉.Slack 等常用沟通工具,而且很容易做到告警信息进行去重,降噪,分组等, ...

  3. 基于SqlSugar的数据库访问处理的封装,在.net6框架的Web API上开发应用

    我前面几篇随笔介绍了关于几篇关于SqlSugar的基础封装,已经可以直接应用在Winform项目开发上,并且基础接口也通过了单元测试,同时测试通过了一些Winform功能页面:本篇随笔继续深化应用开发 ...

  4. Lab_1:练习1——理解通过make生成执行文件的过程

    lab_0 清华大学ucore实验环境配置详细步骤!(小白入) lab_1 清华大学ucore bootload启动ucore os(预备知识) Lab_1:练习1--理解通过make生成执行文件的过 ...

  5. Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    错误描述 在DBeaver执行DDL语句时报错:SQL 错误 [1293] [HY000]: Incorrect table definition; there can be only one TIM ...

  6. 【Electron】使用 build-tools 在 Windows 中编译 electron

    [Electron]使用 build-tools 在 Windows 中编译 electron 提前准备 预留好磁盘空间 Git 缓存目录:%UserProfile%/.git_cache ,大概有 ...

  7. 生成器对象(自定义迭代器),自定义range方法,模块

    自定义迭代器 一 .生成器与yield ''' 我们得到一个迭代器通常都是调用可迭代对象的__iter__方法 ,例如 list.iter() 得到一个迭代器, 但是当list很大时候,就违背了pyt ...

  8. Hbase数据库安装部署

    Hbase单机版安装 hbase介绍 HBase – Hadoop Database是一个分布式的.面向列的开源数据库,该技术来源于Chang et al所撰写的Google论文"Bigta ...

  9. 143_Power BI&Power Pivot月度、季度、半年度、全年同维度展示

    博客:www.jiaopengzi.com 焦棚子的文章目录 请点击下载附件 一.背景 最近在做下一年度的预算,做出来需要月度.季度.半年度.全年都展示出来,在做测算的是时候,默认的透视表已经无法满足 ...

  10. Windows 程序安装与更新方案: Clowd.Squirrel

    我的Notion Clowd.Squirrel Squirrel.Windows 是一组工具和适用于.Net的库,用于管理 Desktop Windows 应用程序的安装和更新. Squirrel.W ...