Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add Word watermark based on Spire.Cloud.Word in C #

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to add Word watermark based on Spire.Cloud.Word in C#. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Overview

Spire.Cloud.Word provides watermarksApi API for adding watermarks, including text watermarking (SetTextWatermark) and image watermarking (SetImageWatermark), which will be described in detail in this document.

About Spire.Cloud

Spire.Cloud is a cloud Office document processing software that supports online creation, editing, saving and printing of Office (Word / Excel / PPT) documents. It supports .NET, Java, PHP, Python, JavaScript and other programming languages. It can operate documents in DOC, DOCX, XLS, XLSX, PPT, PPTX, PDF and other formats.

You can call the interface provided by Spire.Cloud Web API SDK to operate Word, Excel, PPT and PDF documents. This paper takes the Word document manipulation by calling Spire.Cloud.Word.SDK in the VS program as an example to add watermarks.

Specific steps:

Step 1:dll file acquisition and reference.

Method 1: download Spire.Cloud.Word.Sdk through the official website.

Method 2: download the Spire.Cloud.Word.SDK package from the Nuget website, and add a reference to the dll of Spire.Cloud.Word.Sdk.dll and its dependencies to the program (as shown in the following figure), or search for installation through Nuget in the VS program, as shown here.

Step 2:ID and Key acquisition. Sign up for an account on the Ice Blue Cloud web page and log in, create an application in the "my applications" section, and get App ID and App Key.

Step 3: set the file path. In the "my documents" section of the Ice Blue Cloud web page, create two folders, input and output, respectively, and add the tested Word documents and images to the input folder. Through the VS code program, the generated watermarked Word documents will be saved directly to the output folder. For specific code operation methods, please refer to the following.

[example 1] add Word text watermark

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 = "Application App ID"; static String appKey = "Application App Key" Static void Main (string [] args) {/ / configure account information Configuration wordConfiguration = new Configuration (appId, appKey); / / create TablesApi instance WatermarksApi watermarksApi = new WatermarksApi (wordConfiguration); / / set folder, test document, watermark word and watermark style 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, "Arial") {Color = new Color (100,100,100)}} / / call the SetTextWatermark API to add a text watermark to the Word document and save it to the specified file path string destFilePath = "output/SetTextWatermark.docx"; watermarksApi.SetTextWatermark (name, body, inputfolder, storage, password, destFilePath);}

Adding effect of text watermark:

[example 2] add a picture watermark

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 = "application App ID"; static String appKey = "application App Key"; static void Main (string [] args) {/ / configure account information Configuration wordConfiguration = new Configuration (appId, appKey) / / create TablesApi instance WatermarksApi watermarksApi = new WatermarksApi (wordConfiguration); / / set folder, test document, image for watermark, watermark style, etc. 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"; / / call the API SetImageWatermark to add image watermark to the Word document and save it to the specified file path string destFilePath = "output/SetImageWatermark.docx"; watermarksApi.SetImageWatermark (name, imagePath, inputfolder, storage, scaling, washout, password, destFilePath) }}}

Add effect of image watermark:

This is the end of this article on "how to add Word watermark based on Spire.Cloud.Word". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report