翻譯|使用教程|編輯:胡濤|2022-07-11 15:45:07.620|閱讀 205 次
概述:本節(jié)將演示如何使用 Spire.Doc 在 C# 中為 Word 文檔添加文本水印和圖像水印。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
文字水印和圖片水印是Word文檔中的兩種水印。文本水印總是顯示一些與單詞上下文相關(guān)的附加信息。而圖像水印用于使Word文檔更具吸引力。本節(jié)將演示如何使用 Spire.Doc 在 C# 中為 Word 文檔添加文本水印和圖像水印。
using Spire.Doc;
namespace SetImageWatermark
{
class Program
{
static void Main(string[] args)
{
{
//create a new instance of Document and load the document from file.
Document doc = new Document();
doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);
//create a new instance of the PictureWatermark and load the picture from file.
PictureWatermark picture = new PictureWatermark();
picture.Picture = System.Drawing.Image.FromFile("logo.png");
//set the image watermark scaling and Washout property
picture.Scaling = 20;
picture.IsWashout = false;
//add the picture watermark
doc.Watermark = picture;
//save the document to file
doc.SaveToFile("ImageWatermark.docx", FileFormat.Docx2013);
}
}
}
}
using Spire.Doc;
using Spire.Doc.Documents;
using System.Drawing;
namespace SetTextWatermark
{
class Program
{
static void Main(string[] args)
{
{
//create a new instance of Document and load the document from file.
Document doc = new Document();
doc.LoadFromFile("Sample.docx", FileFormat.Docx2013);
//create a new instance of the TextWatermark
TextWatermark txtWatermark = new TextWatermark();
//set the text watermark with text string, font, color and layout.
txtWatermark.Text = "Confidential";
txtWatermark.FontSize = 45;
txtWatermark.Color = Color.Green;
txtWatermark.Layout = WatermarkLayout.Diagonal;
//add the text watermark
doc.Watermark = txtWatermark;
//save the file.
doc.SaveToFile("TextWatermark.docx", FileFormat.Docx2013);
}
}
}
}
歡迎下載|體驗(yàn)更多E-iceblue產(chǎn)品
獲取更多信息請(qǐng)咨詢(xún) ;技術(shù)交流Q群(767755948)
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn