bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

C#如何基于Spire.Cloud.Word添加Word水印-創新互聯

這篇文章將為大家詳細講解有關C#如何基于Spire.Cloud.Word添加Word水印,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

創新互聯致力于互聯網網站建設與網站營銷,提供做網站、網站設計、網站開發、seo優化、網站排名、互聯網營銷、微信小程序定制開發、公眾號商城、等建站開發,創新互聯網站建設策劃專家,為不同類型的客戶提供良好的互聯網應用定制解決方案,幫助客戶在新的全球化互聯網環境中保持優勢。

概述

Spire.Cloud.Word提供了watermarksApi接口可用于添加水印,包括添加文本水?。⊿etTextWatermark)、圖片水?。⊿etImageWatermark),本文將對此做詳細介紹。

關于Spire.Cloud

Spire.Cloud是云端 Office 文檔處理軟件,支持在線創建、編輯、保存和打印 Office (Word / Excel / PPT) 文檔,支持 .NET、Java、PHP、Python、JavaScript 等多種編程語言,可操作包括DOC、DOCX、XLS、XLSX、PPT、PPTX、PDF等格式的文檔。

可調用Spire.Cloud Web API SDK 提供的接口對 Word、Excel、PPT、PDF 文檔進行操作,本文以在VS程序中通過調用Spire.Cloud.Word.SDK來操作Word文檔為例,添加水印。

具體步驟:

步驟1:dll文件獲取及引用。

方法1:通過官網下載Spire.Cloud.Word.Sdk 。

方法2:通過Nuget網站下載獲取Spire.Cloud.Word.SDK package,并將Spire.Cloud.Word.Sdk.dll及其依賴項的dll添加引用至程序(如下圖);或者在VS程序中通過Nuget搜索安裝,具體步驟可參考這里。

C#如何基于Spire.Cloud.Word添加Word水印

步驟2:ID及Key獲取。在冰藍云網頁注冊賬號并登陸,在“我的應用”板塊創建應用程序,獲得 App ID 及 App Key。

步驟3:文件路徑設置。在冰藍云網頁“我的文檔”板塊,分別建立input和output兩個文件夾,并將測試的Word文檔和圖片添加在input文件夾下。通過VS代碼程序,生成的帶水印的Word文檔會直接保存至output文件夾下。具體代碼操作方法,請參考以下內容。

 【示例1】添加Word文本水印

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);
 
        }
    }
}

文本水印添加效果:

C#如何基于Spire.Cloud.Word添加Word水印

【示例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);
        }
    }
}

圖片水印添加效果:

C#如何基于Spire.Cloud.Word添加Word水印

關于“C#如何基于Spire.Cloud.Word添加Word水印”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

標題名稱:C#如何基于Spire.Cloud.Word添加Word水印-創新互聯
文章地址:http://vcdvsql.cn/article0/isioo.html

成都網站建設公司_創新互聯,為您提供手機網站建設、域名注冊、虛擬主機、App設計、定制開發、網站導航

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

營銷型網站建設