您现在的位置是:首页 > 文章详情

Aspose-Words文档处理类库

日期:2019-05-28点击:478

简介

Aspose.Words for Java is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without using Microsoft Word®.

官网文档: https://docs.aspose.com/display/wordsjava/Home
官网代码示例: https://github.com/aspose-words/Aspose.Words-for-Java.git

同类别软件: Apache POI

注:

  1. Aspose需要商业授权,POI开源免费
  2. 对于简单的文档关键字替换使用POI
  3. 复杂的表格编辑,使用Aspose中的标签替换
  4. 对于替换参数(数字,文本,表格,图片等),可封装替换参数,增强代码的适用性

代码示例

Java类库

Maven

<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-words</artifactId> <version>19.5</version> <classifier>jdk17</classifier> </dependency>

直接引入Jar

aspose-words-19.5-jdk17.jar

简单示例

加载license

try { License license = new License(); license.setLicense("Aspose.Words.lic"); System.out.println("License set successfully."); } catch (Exception e) { System.out.println("There was an error setting the license: " + e.getMessage()); }

Word->PDF

File file = new File("/Test-01.docx"); Document document = new Document(new FileInputStream(file)); PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); pdfSaveOptions.getOutlineOptions().setHeadingsOutlineLevels(5); OutputStream outputStream = new FileOutputStream("/Test-01.pdf"); document.save(outputStream,pdfSaveOptions);

书签文本替换

document.getRange().getBookmarks().get(bookMakeName).setText(word);
原文链接:https://yq.aliyun.com/articles/703984
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章