概要
Spire.Cloud.WordはwatermarksApiインターフェースは、透かしを追加テキストの透かし(SetTextWatermark)を追加し、画像の透かし(SetImageWatermark)するために使用することができる提供し、この論文では詳細に説明します。
Spire.Cloudについて
Spire.Cloudソフトウェア、サポートを処理するクラウドOfficeドキュメントは、オンラインオフィス(ワード/エクセル/ PPT)のドキュメント、サポート、.NETやJava、PHP、Pythonの、作成、編集、保存し、印刷されたJavaScript や他のプログラミング言語を、操作可能な文書DOC、DOCX、XLS、XLSX、含ま PPT、PPTX、PDF や他のフォーマット。
呼び出し可能Spire.CloudウェブAPI SDKは、WordやExcel、PPT、PDF文書の操作、例えばSpire.Cloud.Word.SDKを呼び出すことにより、Word文書を操作するためのVSプログラムでは、紙、追加透かしのためのインタフェースを提供します。
具体的な手順:
ステップ1: DLLファイルアクセスおよび参照。Nugetウェブサイトによってダウンロードの取得Spire.Cloud.Word.SDKパッケージ、およびSpire.Cloud.Word.Sdk.dll項目DLLの依存(下記参照)のプログラムへの参照を追加し、またはVSにインストールNuget検索プログラムによって、具体的な手順は、参照、本明細書。
ステップ2: IDとキーの取得。でアイスブルークラウドサイト登録アカウント、ログインし、「マイアプリケーション」セクションでアプリケーションを作成し、アプリケーションIDとAppキーを入手。
ステップ3:ファイルパスの設定。アイスブルー雲のページでは、「マイドキュメント」のセクション、すなわち、二つの入力と出力フォルダとテストWord文書の確立とは、入力されたフォルダ内の画像を追加します。プログラムのVSのコードでは、透かしを有する得られたWord文書が出力フォルダに直接保存されます。オペレーションコードの具体的な方法は、以下を参照してください。
[例1]は、テキストの透かしを追加します
using Spire.Cloud.Word.Sdk;
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using Spire.Cloud.Word.Sdk.Model;
using System;
namespace txtwatermark
{
class Program
{
static String appId = "应用程序App ID";
static String appKey = "应用程序App Key";
static void Main(string[] args)
{
//配置账号信息
Configuration wordConfiguration = new Configuration(appId, appKey);
//创建TablesApi实例
WatermarksApi watermarksApi = new WatermarksApi(wordConfiguration);
//设置文件夹、测试文档、水印字样及水印样式等
string inputfolder = "input";
string storage = null;
string password = null;
var document = "testfile.docx";
string name = document;
TextWatermark body = new TextWatermark("Watermark")
{
Layout = TextWatermark.LayoutEnum.Diagonal,
Font = new Font(60, "宋体")
{
Color = new Color(100, 100, 100)
}
};
//调用SetTextWatermark接口添加文本水印到Word文档 ,并保存到指定文件路径
string destFilePath = "output/SetTextWatermark.docx";
watermarksApi.SetTextWatermark(name, body, inputfolder, storage, password, destFilePath);
}
}
}
テキストの透かしの効果を追加します。
[実施例2]画像の透かしを追加します
using Spire.Cloud.Word.Sdk;
using Spire.Cloud.Word.Sdk.Api;
using Spire.Cloud.Word.Sdk.Client;
using System;
namespace ImgWatermark
{
class Program
{
static String appId = "应用程序App ID ";
static String appKey = "应用程序App Key ";
static void Main(string[] args)
{
//配置账号信息
Configuration wordConfiguration = new Configuration(appId, appKey);
//创建TablesApi实例
WatermarksApi watermarksApi = new WatermarksApi(wordConfiguration);
//设置文件夹、测试文档、用于水印的图片及水印样式等
string inputfolder = "input";
string storage = null;
int scaling = 120;
bool washout = true;
string password = null;
var document = "testfile.docx";
string name = document;
string imagePath = "input/logo.png";
//调用SetImageWatermark接口添加图片水印到Word文档 ,并保存到指定文件路径
string destFilePath = "output/SetImageWatermark.docx";
watermarksApi.SetImageWatermark(name, imagePath, inputfolder, storage, scaling, washout, password, destFilePath);
}
}
}
画像の透かし効果を追加します。
(この記事の終わり)