本文介绍如何使用 Node.js 的 REST API 在 Word 中插入脚注。您将学习如何使用 Aspose.Words for Node.js Cloud SDK 和 Node.js Low Code API 在 Word 中添加脚注。我们将讨论在将脚注添加到文档之前可以设置的各种属性。
先决条件
- 创建帐户并获取 API 凭证
- 下载 适用于 Node.js 的 Aspose.Words Cloud SDK 在 Word 文件中添加脚注
- 使用上述 SDK 设置 Nodej.s 解决方案项目以创建尾注
使用 Node.js REST API 在 Word 中添加脚注的步骤
- 通过提供客户端 ID 和密钥来实例化 WordsApi 对象以插入尾注
- 读取输入的Word文件并将其存储在文件流中
- 通过设置各种属性来创建 FootnoteInsert 对象
- 通过设置请求、FootnoteInsert 和目标文件名来创建 InsertFootnoteOnlineRequest 方法
- 调用 在线插入脚注 方法在源 Word 文件中插入脚注
- 从结果中获取输出流并将其保存在磁盘上
上述步骤描述了如何使用 Node.js 的 REST API 在 Word 中创建脚注。首先,将源 Word 文件加载到 FileStream 对象中,并使用 FootnoteInsert 类创建脚注。使用此脚注创建 InsertFootnoteOnlineRequest,最终可以使用 InsertFootnoteOnline 方法在 Word 文件中创建脚注。
使用 Node.js REST API 在 Word 中创建脚注的代码
此示例代码演示了如何使用 Node.js 的 REST API 在 Word 中添加脚注。FootnoteInsert 类包含各种属性,例如 Position,可以将其设置为指向范围起始节点和引用标记的链接。调用的响应包含 Document.TryGetValue() 方法,该方法将生成的 Word 文件返回到流对象中,以便保存到磁盘或数据库中。
In this topic, we have learned the process of adding a footnote in a Word document. If you are looking to replace text in a Word file, refer to the following article: Replace a Word in Word with Nodej.s REST API.