Bookmarks 接口描述

 

操作Word文档的书签,包括添加书签、删除书签、获取书签和获取书签内容。

接口方法1:getBookmarks()返回文档中包含的书签信息列表

HTTP请求方法:GET

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/bookmarks

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
password string 原文档密码,没有则为null

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace GetBookmarks
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "getBookmarks.docx";
            string folder = "input";
            string password = null;
            string storage = null;
            var response = bookmarksApi.GetBookmarks(name, folder, storage, password);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;
import spire.cloud.word.sdk.client.model.BookmarkInfo;
import java.util.List;

public class GetBookmarks {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "getBookmarks.docx";
        String folder = "input";
        String password = null;
        String storage = null;
        List<BookmarkInfo> response = bookmarksApi.getBookmarks(name, folder, storage, password);
    }
}

接口方法2:addBookmark()在指定段落添加书签

HTTP 请求方法:POST

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/bookmarks

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
password string 原文档密码,没有则为null
startParagraphPath string 开始添加书签的段落
startIndexInParagraph integer 开始插入书签在段落中的索引
endParagraphPath string 结束添加书签的段落
endIndexInParagraph integer 结束插入书签在段落中的索引
bookmarkName string 书签名称
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace AddBookmark
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "addBookmark.docx";
            string startParagraphPath = "Section/0/Body/0/Paragraph/0";
            int startIndexInParagraph = 0;
            string endParagraphPath = "Section/0/Body/0/Paragraph/2";
            int endIndexInParagraph = 2;
            string password = null;
            string bookmarkName = "Text_bookmark";
            string folder = "input";
            string destFilePath = "output/addBookmark_output.docx";
            string storage = null;
            bookmarksApi.AddBookmark(name, startParagraphPath, startIndexInParagraph, endParagraphPath,
                endIndexInParagraph, bookmarkName, destFilePath, folder, storage, password);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;

public class AddBookmark {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "addBookmark.docx";
        String startParagraphPath = "sections/0/paragraphs/0";
        int startIndexInParagraph = 0;
        String endParagraphPath = "sections/0/paragraphs/0";
        int endIndexInParagraph = 2;
        String password = null;
        String bookmarkName = "Test_bookmark";
        String folder = "input";
        String destFilePath = "output/addBookmark_output.docx";
        String storage = null;
        bookmarksApi.addBookmark(name, startParagraphPath, startIndexInParagraph, endParagraphPath,
                endIndexInParagraph, bookmarkName, destFilePath, folder, storage, password);
    }
}

接口方法3:deleteBookmark()删除指定书签

HTTP 请求方法:DELETE

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/bookmarks

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
password string 原文档密码,没有则为null
bookmarkName string 书签名称
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace DeleteBookmark
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "deleteBookmark.docx";
            string bookmarkName = "Text_bookmark";
            string folder = "input";
            string password = null;
            string storage = null;
            string destFilePath = "output/deleteBookmark_output.docx";
            bookmarksApi.DeleteBookmark(name, bookmarkName, destFilePath, folder, storage, password);
        }
    }
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;

public class DeleteBookmark {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "deleteBookmark.docx";
        String storage = null;
        String folder = "Bookmark";
        String bookmarkName = "Test";
        String password = null;
        String destFilePath = "output/deleteBookmark_out.docx";
        bookmarksApi.deleteBookmark(name, bookmarkName, destFilePath, folder, storage, password);
    }
}

接口方法4:getBookmarkContent()获取指定书签内容

HTTP 请求方法:GET

请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/bookmarkContent

请求参数:

参数 是否必选 类型 可选值范围 说明
name string 原文档名称
folder string 存放原文档的文件夹,没有则为null
storage string 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null
password string 原文档密码,没有则为null
bookmarkName string 书签名称
destFilePath string 结果文档的存贮路径,如果省略该参数,则默认存到根目录

代码示例:

  • .NET
  • Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;

namespace GetBookmarkContent
{
    class Program
    {
        static string appId = "your id";
        static string appKey = "your key";
        static string baseUrl = "https://api.e-iceblue.cn";
        static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
        static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);
        static void Main(string[] args)
        {
            string name = "getBookmarkContent.docx";
            string bookmarkName = "Test";
            string folder = "input";
            string password = null;
            var response = bookmarksApi.GetBookmarkContent(name, bookmarkName, folder, password);
        }
    }
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;

public class GetBookmarkContent {

    static String appId = "your id";
    static String appKey = "your key";
    static String baseUrl = "https://api.e-iceblue.cn";
    static Configuration wordConfiguration = new Configuration(appId, appKey, baseUrl);
    static BookmarksApi bookmarksApi = new BookmarksApi(wordConfiguration);

    public static void main(String[] args) throws ApiException {

        String name = "getBookmarkContent.docx";
        String bookmarkName = "Test";
        String folder = "input";
        String password = null;
        String storage = null;
        String response = bookmarksApi.getBookmarkContent(name, bookmarkName, folder, storage, password);
    }
}