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);
相关文章
|
7月前
|
缓存 Linux Windows
Linux环境aspose插件word转pdf中文乱码解决方案
Linux环境aspose插件word转pdf中文乱码解决方案
725 0
|
10月前
|
前端开发
前端如何支持PDF、Excel、Word在线预览 #42
前端如何支持PDF、Excel、Word在线预览 #42
515 0
Word处理控件Spire.Doc常见问题解答
为方便使用者快速掌握和了解Spire.Doc,本文列举了Word处理控件Spire.Doc常见问题及解答欢迎下载体验!
|
9月前
|
前端开发 C#
C# 基于NPOI+Office COM组件 实现20行代码在线预览文档(word,excel,pdf,txt,png)
C# 基于NPOI+Office COM组件 实现20行代码在线预览文档(word,excel,pdf,txt,png)
|
6月前
|
Cloud Native Go 开发者
使用WPS自动化转换办公文档: 将Word, PowerPoint和Excel文件转换为PDF
使用WPS自动化转换办公文档: 将Word, PowerPoint和Excel文件转换为PDF
102 0
|
Windows
在word、excel中如果运用VBA进行编程?
在word、excel中如果运用VBA进行编程?
在word、excel中如果运用VBA进行编程?
C# Aspose.Words 用法
C# Aspose.Words 用法
178 0
C# Aspose.Words 用法
|
Python
用Python开发一个PDF转Word的小工具
PDF格式的文档在我们使用的时候比较方便,因为不会因为编辑器和其他原因导致格式不正常,但是有时候我们又需要对这个文档进行修改,这时候我们就需要将PDF解析成word格式的。网上有很多的格式转换的网站和软件,但是大多数只能免费使用几次,后面再使用的话就要升级vip了,那如果我们自己写一个pdf转换的程序,是不是很方便又很niuability呢?
467 0
用Python开发一个PDF转Word的小工具
带你读《Word/Excel/PPT2019应用与技巧大全》之三:Word文档的基本格式编排
本书以Office 2019为软件平台,通过大量详尽、直观的操作解析,带领读者快速精通三大组件的功能及应用,轻松晋级办公达人。

热门文章

最新文章