resourceintensive(resource.irf 下载)

阿斯波斯。word可以在没有安装Microsoft Office的机器上运行。的所有Aspose组件都是独立的,不需要Microsoft Corporation的授权。一句话,Aspose。从安全性、稳定性、可扩展性、速度、价格和自动化来看,Words是一个不错的选择。

resourceintensive(resource.irf 下载)

让我们一起学习。

一、环境搭建

1。首先,您需要下载一个aspose插件jar包,并将其放入项目中。用的思路,jar包可以从网盘下载:

链接:https://pan.baidu.com/s/1jISO-TPEyLgC8RTmMJGRQw提取代码:9ju8

2 .下载完所需的jar包后,idea需要引入jar包,从编译的层面考虑将jar包安装到本地仓库,解决编译打包出错的问题。
A .首先确定mvn -v是否可以使用,将下载的jar包放在项目外的本地文件夹中。
B .其次,执行mvn install将本地jar包安装到本地仓库,如下图:
mvn install:install-file-dgroupid = com . aspose-dart ified = aspose-words-d version = 15 . 8 . 0-d packaging = jar-dfile = dfile

执行完成后,可以检查本地仓库中是否存在这个包。
[br/]3。在项目中添加对本地仓库的依赖关系:
< dependency & gt;
& lt;groupId & gtcom.aspose & lt/groupId & gt;
& lt;artifactId & gtaspose-words & lt;/artifact id & gt;
& lt;版本& gt15 . 8 . 0 & lt;/version & gt;
& lt;/dependency & gt;

二、添加license文件

在springboot中,需要将它放在resource/static文件下,这样它才能被读取。

& lt?xml版本= & # 34;1.0"编码= & # 34;UTF-8 & # 34;?& gt& lt许可证& gt& lt数据& gt& lt产品& gt& lt产品& gt阿斯波斯。Java合计& lt/Product & gt;& lt产品& gt阿斯波斯。Java单词& lt/Product & gt;& lt/Products & gt;& ltEditionType & gt企业& lt/edition type & gt;& ltSubscriptionExpiry & gt20991231 & lt/subscription expiry & gt;& ltLicenseExpiry >20991231 & lt/license expiry & gt;& lt序列号& gt8 bfe 198 c-7f0c-4ef 8-8ff 0-ACC 3237 bf0d 7 & lt;/serial number & gt;& lt/Data & gt;& lt签名& gtsnllkgmudf 0 r 8 o 1 kkilwagdfs 2 bvjb/2xp 8 p 5 iudvfzxmhppo+d0ran 1 p 9 tkdjv 4 abwagkxj 3 jcqtqe/2 irfqwnpf 8 ITN 8 afzlv 3 jpyed 3y we7 it 55 gz 6 eijupc 7 akeooht B4 w 2 fpox 58 wwof 3 SNP 6 sk 6 jdfiaugehyj 9 pju = & lt;/Signature & gt;& lt/License & gt;

三、创建工具类

包com . ruo yi . system . utils;导入com . aspose . words . document;导入com . aspose . words . license;导入com . aspose . words . save format;导入Java . io . *;public class word 2 pdfasposeutil { public static boolean get license(InputStream is){ boolean result = false;请试用{ License aposeLic = new License();apose lic . set license(is);结果=真;} catch(Exception e){ e . printstacktrace();}最后{如果(是!= null){ try { is . close();} catch(io exception e){ e . printstacktrace();} } }返回结果;}公共静态布尔doc2pdf(InputStream license,String inPath,String outPath,int type) { if(license!=null){ if(!GetLicense(License)) {//验证如果许可证未通过验证,转换后的pdf文档将被添加水印并返回false} } FileOutputStream os = null请尝试{ long old = system . current time millis();File File = new File(out path);//新建空白色pdf文档OS = new file output stream(file);文档doc =新文档(in path);// Address是要转换的word文档doc.save(os,type);//全面支持doc、docx、ooxml、rtf html、opendocument、pdf、//epub、XPS、swf转换long now = system . current time millis();system . out . println(& # 34;Pdf转换成功,共花费时间:& # 34;+((现旧)/1000.0)+& # 34;第二& # 34;);//转换时间} catch(异常e){ e . printstacktrace();返回false}最后{ if (os!= null){ try { OS . flush();OS . close();} catch(io exception e){ e . printstacktrace();} } }返回true} public static void main(String[]arg)抛出FileNotFoundException { File File = new File(& # 34;d:\ \ license . XML & # 34;);InputStream is = new file InputStream(file);String docPath = & # 34D:\生产环境部署手册. & # 34;String pdfPath = & # 34D:\生产环境部署Manual.pdf & # 34;;String htmlPath = & # 34D:\生产环境部署Manual.html & # 34;;String JPEGPath = & # 34D:\生产环境部署Manual.jpeg & # 34;;// int type =SaveFormat。PDF//全面支持doc,docx,ooxml,rtf html,打开文档,pdf,//word 2 pdpfasposeutil . doc 2 pdf(is,docpath,pdf path,type);// int html=SaveFormat。HTML//word 2 pdasposeutil . doc 2 pdf(is,docPath,htmlPath,html);int docx = SaveFormat.JPEG;//word 2 pdasposeutil . doc 2 pdf(is,htmlPath,JPEGPath,SaveFormat。JPEG);//HTML转图片//word 2 pdpfasposeutil . doc 2 pdf(is,htmlpath,docpath,save format . docx);Word2PdfAsposeUtil.doc2pdf(is,pdfPath,docPath,SaveFormat。JPEG);}}四。在sprincloud(& # 34;/common/test & # 34;)公共布尔测试(String fileName,String wordPath,String pdf path){ InputStream stream = thread . current thread()。getContextClassLoader()。getResourceAsStream(& # 34;static/license . XML & # 34;);String docPath = & # 34D:\生产环境部署手册. & # 34;String pdfPath = & # 34D:\生产环境部署Manual.pdf & # 34;;String htmlPath = & # 34D:\生产环境部署Manual.html & # 34;;String JPEGPath = & # 34D:\生产环境部署Manual.jpeg & # 34;;// int type =SaveFormat。PDF//全面支持doc,docx,ooxml,rtf html,打开文档,pdf,//word 2 pdpfasposeutil . doc 2 pdf(is,docpath,pdf path,type);// int html=SaveFormat。HTML//word 2 pdasposeutil . doc 2 pdf(is,docPath,htmlPath,html);int docx = SaveFormat.JPEG;//word 2 pdasposeutil . doc 2 pdf(is,htmlPath,JPEGPath,SaveFormat。JPEG);//HTML转图片//word 2 pdpfasposeutil . doc 2 pdf(is,htmlpath,docpath,save format . docx);Word2PdfAsposeUtil.doc2pdf(is,pdfPath,docPath,SaveFormat。JPEG);}

代码截图

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。

作者:美站资讯,如若转载,请注明出处:https://www.meizw.com/n/280232.html

发表回复

登录后才能评论