开发者社区> M'tai'n> 正文

Aspose-Words文档处理类库

简介: Aspose-Words文档处理类库
+关注继续查看

简介

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);

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
在word、excel中如果运用VBA进行编程?
在word、excel中如果运用VBA进行编程?
23 0
针对word.docx文档的关键词索引器
针对word.docx文档的关键词索引器
31 0
C# Aspose.Words 用法
C# Aspose.Words 用法
84 0
Word处理控件Spire.Doc常见问题解答
为方便使用者快速掌握和了解Spire.Doc,本文列举了Word处理控件Spire.Doc常见问题及解答欢迎下载体验!
164 0
Python 技术篇-利用Office VBA实现word文档转化为pdf文档实例演示
Python 技术篇-利用Office VBA实现word文档转化为pdf文档实例演示
140 0
使用ABAP操作office Word文档
使用ABAP操作office Word文档
130 0
+关注
M&#39;tai&#39;n
文章
问答
视频
文章排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载