操作 Word 文档的内置文档属性和自定义文档属性,包括获取、添加和删除。
接口方法 1: getCustomDocumentProperties() 获取自定义文档属性
HTTP 请求方法:GET
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/customDocumentProperties
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
password | 否 | string | 原文档密码,没有则为null | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace GetCustomDocumentProperties
{
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
static void Main(string[] args)
{
string name = "getCustomDocumentProperties.docx";
string password = null;
string folder = "input";
string storage = null;
var response = documentPropertiesApi.GetCustomDocumentProperties(name, password, folder, storage);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.DocumentPropertiesApi;
import spire.cloud.word.sdk.client.model.*;
import java.util.*;
public class GetCustomDocumentProperties {
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "getCustomDocumentProperties.docx";
String password = null;
String folder = "input";
String storage = null;
List<CustomDocumentProperty> response = documentPropertiesApi.getCustomDocumentProperties(name, password, folder, storage);
}
}
接口方法 2: addCustomDocumentProperties() 添加自定义文档属性
HTTP 请求方法:POST
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/customDocumentPropertiest
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
password | 否 | string | 原文档密码,没有则为null | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
properties | 是 | array | 自定义的文档属性 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;
using System.Collections.Generic;
namespace AddCustomDocumentProperties
{
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
static void Main(string[] args)
{
string name = "addCustomDocumentProperties.docx";
List properties = new List();
properties.Add(new CustomDocumentProperty("propertiesName1", "propertiesValue1"));
properties.Add(new CustomDocumentProperty("propertiesName2", "propertiesValue2"));
string password = null;
string folder = "input";
string destFilePath = "output/addCustomDocumentProperties_out.docx";
string storage = null;
documentPropertiesApi.AddCustomDocumentProperties(name, properties, destFilePath, password, folder, storage);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.DocumentPropertiesApi;
import spire.cloud.word.sdk.client.model.*;
import java.util.*;
public class AddCustomDocumentProperties {
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "addCustomDocumentProperties.docx";
List<CustomDocumentProperty> properties = new ArrayList<CustomDocumentProperty>();
properties.add(new CustomDocumentProperty("propertiesName1", "propertiesValue1"));
properties.add(new CustomDocumentProperty("propertiesName2", "propertiesValue2"));
String password = null;
String folder = "input";
String destFilePath = "output/addCustomDocumentProperties_out.docx";
String storage = null;
documentPropertiesApi.addCustomDocumentProperties(name, properties, destFilePath, password, folder, storage);
}
}
接口方法 3: deleteCustomDocumentProperty() 删除自定义文档属性
HTTP 请求方法:DELETE
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/customDocumentProperties
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
password | 否 | string | 原文档密码,没有则为null | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
properties | 是 | array | 自定义的文档属性 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace DeleteCustomDocumentProperty
{
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
static void Main(string[] args)
{
string name = "deleteCustomDocumentPropertie.docx";
string propertieName = "E-iceblue";
string password = null;
string folder = "input";
string storage = null;
string destFilePath = "output/deleteCustomDocumentProperties_output.docx";
documentPropertiesApi.DeleteCustomDocumentProperty(name, propertieName, destFilePath, password, folder, storage);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.DocumentPropertiesApi;
public class DeleteCustomDocumentProperty {
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "deleteCustomDocumentPropertie.docx";
String propertieName = "E-iceblue";
String password = null;
String folder = "input";
String storage = null;
String destFilePath = "output/deleteCustomDocumentProperties_output.docx";
documentPropertiesApi.deleteCustomDocumentProperty(name, propertieName, destFilePath, password, folder, storage);
}
}
接口方法 4: getBuiltinDocumentProperties() 获取内置文档属性
HTTP 请求方法:GET
请求 URL:https://api.e-iceblue.cn/v1/word/document/{name}/builtinDocumentProperties
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
password | 否 | string | 原文档密码,没有则为null | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace GetBuiltinDocumentProperties
{
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
static void Main(string[] args)
{
string name = "getBuiltinDocumentProperties.docx";
string password = null;
string folder = "input";
string storage = null;
var response = documentPropertiesApi.GetBuiltinDocumentProperties(name, password, folder, storage);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.DocumentPropertiesApi;
import spire.cloud.word.sdk.client.model.BuiltinDocumentProperties;
public class GetBuiltinDocumentProperties {
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 DocumentPropertiesApi documentPropertiesApi = new DocumentPropertiesApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "getBuiltinDocumentProperties.docx";
String password = null;
String folder = "input";
String storage = null;
BuiltinDocumentProperties response = documentPropertiesApi.getBuiltinDocumentProperties(name, password, folder, storage);
}
}