Aspose最新版文档格式转换使用破解
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最新版文档格式转换使用破解的更多相关文章
- windwos文档格式转换成unix格式
在工作学习中我们避免不了需要将一些脚本和命令记录在笔记里面,我使用的是有道云笔记,每当我将上次记录在有道云的脚本复制出来进行使用的时候,总会报一些奇怪的错误,要么是包含换行符,要么就是格式不对,但是我 ...
- Java利用jacob实现文档格式转换
实现文档格式之间的转换,我使用的是jacob-1.7版本,需要jacob.jar来调用activex控件,本机需安装WPS/office,还需要jacob.jar以及jacob.dll 其中: ...
- Python - 文档格式转换(CSV与JSON)
- 【好文翻译】一步一步教你使用Spire.Doc转换Word文档格式
背景: 年11月,微软宣布作为ECMA国际主要合作伙伴,将其开发的基于XML的文件格式标准化,称之为"Office Open XML" .Open XML的引进使office文档结 ...
- C#word(2007)操作类--新建文档、添加页眉页脚、设置格式、添加文本和超链接、添加图片、表格处理、文档格式转化
转:http://www.cnblogs.com/lantionzy/archive/2009/10/23/1588511.html 1.新建Word文档 #region 新建Word文档/// &l ...
- 导出WPS office文档格式的说明
针对microsoft office的文档格式,WPS office分别提供wps对应doc,et对应xls两种格式,word和excel是办公系统使用的普及度最广的文件格式,而国内的政府行政单 ...
- 【itext】7步制作兼容各种文档格式的Itext5页眉页脚 实现page x pf y
itext5页眉页脚工具类,实现page x of y 完美兼容各种格式大小文档A4/B5/B3,兼容各种文档格式自动计算页脚XY轴坐标 鉴于没人做的这么细致,自己就写了一个itext5页眉页脚工具类 ...
- Java导出freemarker实现下载word文档格式功能
首先呢,先说一下制作freemarker模板步骤, 1. 在WPS上写出所要的下载的word格式当做模板 2. 把模板内不固定的内容(例:从数据库读取的信息)写成123或者好代替的文字标注 3. 把固 ...
- wordxml文档格式说明
近期需要对word xml文档进行各种操作,需要熟悉 wordxml 文档格式,搜索了一番后发现 open xml sdk 官网的文档最好.就按照官网说明来记录一番 1 word xml 文档基本格式 ...
随机推荐
- 聊聊buffer和cache的区别以及是什么?
buffer 众所周知,想把数据写入磁盘,肯定要先把数据文件读到内存中,当修改完这个文件时,不会立即写入磁盘,为了减少磁盘IO,提高性能,所有会留存一段时间再写入磁盘,这就是buffer cache ...
- Django学习——静态文件配置、request对象方法、pycharm如何链接数据库、Django如何指定数据库、Django orm操作
静态文件配置 # 1.静态文件 网站所使用的已经提前写好的文件 css文件 js文件 img文件 第三方文件 我们在存储静态文件资源的时候一般默认都是放在static文件夹下 # 2.Django静态 ...
- 论文解读(Graphormer)《Do Transformers Really Perform Bad for Graph Representation?》
论文信息 论文标题:Do Transformers Really Perform Bad for Graph Representation?论文作者:Chengxuan Ying, Tianle Ca ...
- Linux服务器安全加固10条建议
以下是服务器安全加固的步骤,本文以腾讯云的CentOS7.7版本为例来介绍,如果你使用的是秘钥登录服务器1-5步骤可以跳过. 设置复杂密码 服务器设置大写.小写.特殊字符.数字组成的12-16位的复杂 ...
- 使用NFS作为Glance存储后端
NFS服务介绍 NFS网络文件系统提供了一种在类UNIX系统上共享文件的方法.目前NFS有3个版本:NFSv2.NFSv3.NFSv4.CentOS7默认使用NFSv4提供服务,优点是提供了有状态的连 ...
- call()、apply()、arguments
一.call(),apply() 1.作为函数对象(指函数方法名,不带括号)的方法,需要通过函数对象调用:当对函数调用这两个方法时都会调用函数执行. <script> // 这个函数中,f ...
- 109_Power Pivot客户ABC(帕累托)分析度量值写法(非计算列)
博客:www.jiaopengzi.com 焦棚子的文章目录 请点击下载附件 1.背景 客户ABC分析,一般的套路是在计算列中把客户ABC分类,便于后续维度使用.今天用度量值的方式写一个ABC的分类. ...
- ethtools-网卡适配器管理
查看网卡适配器配置信息,并且我们可以通过它修改网卡适配器的双工模式. 1.安装Ethtools [root@localhost ~]# yum -y install ethtools 2.命令语法 语 ...
- Es图形化软件使用之ElasticSearch-head、Kibana,Elasticsearch之-倒排索引操作、映射管理、文档增删改查
今日内容概要 ElasticSearch之-ElasticSearch-head ElasticSearch之-安装Kibana Elasticsearch之-倒排索引 Elasticsearch之- ...
- CabloyJS也有工作流引擎了,是你想要的吗?
前言 众所周知,NodeJS作为后端开发语言和运行环境,样样都好,就差一个NodeJS工作流引擎.CabloyJS 4.0重点开发了NodeJS工作流引擎,并作为内置的基础核心模块,近一步拓展了Nod ...