操作Word文档的背景,包括获取背景颜色,设置背景颜色,背景图片,删除背景颜色和图片。
接口方法1:getBackgroundColor()获取文档背景色
HTTP请求方法:GET
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/background/color
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
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 GetBackgroundColor
{
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
static void Main(string[] args)
{
string name = "getBackgroundColor.docx";
string password = null;
string folder = "input";
var response = backgroundApi.GetBackgroundColorAsync(name, password, folder);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;
import spire.cloud.word.sdk.client.model.Color;
public class GetBackgroundColor {
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "getBackgroundColor.docx";
String password = null;
String folder = "input";
String storage = null;
Color response = backgroundApi.getBackgroundColor(name, password, folder, storage);
}
}
接口方法2:setBackgroundColor()获取文档背景色
HTTP请求方法:PUT
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/background/color
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
color | 是 | Object | { "red": 0-255, "green": 0-255, "blue": 0-255 } | 背景颜色 |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;
namespace SetBackgroundColor
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static void Main(string[] args)
{
Configuration wordConfiguration = new Configuration(appId, appKey);
BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
string name = "setBackgroundColor.docx";
Color color = new Color(255, 1, 1);
string password = null;
string folder = "input";
string destFilePath = "output/setBackgroundColor_output.docx";
string storage = null;
backgroundApi.SetBackgroudColor(name, color, folder, storage, password, destFilePath);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;
import spire.cloud.word.sdk.client.model.Color;
public class SetBackgroundColor {
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "setBackgroundColor.docx";
Color color = new Color(127, 255, 170);
String password = null;
String folder = "input";
String destFilePath = "output/setBackgroundColor_output.docx";
String storage = null;
backgroundApi.setBackgroundColor(name, color, destFilePath, folder, storage, password);
}
}
接口方法3:setBackgroundImageInRequest()设置文档背景图片
HTTP请求方法:PUT
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/background/imageInRequest
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
inputImage | 是 | file | 图片文件 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace SetBackgroundImage
{
class Program
{
static string appId = "your id";
static string appKey = "your key";
static void Main(string[] args)
{
Configuration wordConfiguration = new Configuration(appId, appKey);
BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
string name = "setBackgroundImage.docx";
string imagePath = "input/Background.png";
string folder = "input";
string storage = null;
string password = null;
string destFilePath = "output/setBackgroundImage_output.docx";
backgroundApi.SetBackgroudImage(name, imagePath, folder, storage, password, destFilePath);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;
import java.io.File;
public class SetBackgroundImageInRequest {
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "setBackgroundImageWithImgFile.docx";
File inputImage = new File("inputFile/Background.png");
String password = null;
String folder = "input";
String destFilePath = "output/setBackgroundImageInRequest_output.docx";
String storage = null;
backgroundApi.setBackgroundImageInRequest(name, inputImage, destFilePath, folder, storage, password);
}
}
接口方法4:setBackgroundImage()设置文档背景图片
HTTP请求方法:PUT
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/background/image
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
imagePath | 是 | string | 图片路径 | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System.IO;
namespace SetBackgroundImageInRequest
{
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
static void Main(string[] args)
{
string name = "setBackgroundImageInRequest.docx";
string folder = "input";
string password = null;
string storage = null;
string imagePath = "../../inputFile/background.png";
System.IO.Stream Imagefs = new FileStream(imagePath, FileMode.Open);
string destFilePath = "output/setBackgroundImageInRequest_output.docx"; ;
backgroundApi.SetBackgroundImageInRequest(name, Imagefs, destFilePath, folder, storage, password);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;
import java.io.File;
public class SetBackgroundImage {
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "setBackgroundImage.docx";
String imagePath = "input/Background.png";
String password = null;
String folder = "input";
String destFilePath = "output/setBackgroundImage_output.docx";
String storage = null;
backgroundApi.setBackgroundImage(name, imagePath, destFilePath, folder, storage, password);
}
}
接口方法5:deleteBackground()删除文档背景
HTTP 请求方法:DELETE
请求URL:https://api.e-iceblue.cn/v1/word/document/{name}/background
请求参数:
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
name | 是 | string | 原文档名称 | |
folder | 否 | string | 存放原文档的文件夹,没有则为null | |
storage | 否 | string | 文档存储空间,使用冰蓝云配置的2G空间存贮文档,可设置为null | |
password | 否 | string | 原文档密码,没有则为null | |
destFilePath | 是 | string | 结果文档的存贮路径,如果省略该参数,则默认存到根目录 |
代码示例:
- .NET
- Java
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
namespace DeleteBackground
{
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
static void Main(string[] args)
{
string name = "deleteBackground.docx";
string password = null;
string folder = "input";
string destFilePath = "output/deleteBackground_output.docx";
string storage = null;
backgroundApi.DeleteBackground(name, destFilePath, password, folder, storage);
}
}
}
import spire.cloud.word.sdk.client.*;
import spire.cloud.word.sdk.client.api.*;
public class DeleteBackground {
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 BackgroundApi backgroundApi = new BackgroundApi(wordConfiguration);
public static void main(String[] args) throws ApiException {
String name = "deleteBackground.docx";
String password = null;
String folder = "input";
String destFilePath = "output/deleteBackground_output.docx";
String storage = null;
backgroundApi.deleteBackground(name, destFilePath, password, folder, storage);
}
}