翻譯|使用教程|編輯:胡濤|2022-07-08 10:52:54.627|閱讀 162 次
概述:本文將向您展示如何在 C# 中為 word 文檔設(shè)置圖像背景。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
我們已經(jīng)演示了如何在 C# 中為 word 文檔設(shè)置漸變背景。除了漸變背景,Spire.Doc還支持為word文檔添加圖片背景。本文將向您展示如何在 C# 中為 word 文檔設(shè)置圖像背景。
第 1 步:創(chuàng)建一個(gè)新的 Word 文檔并從文件中加載該文檔。
Document document = new Document(); document.LoadFromFile("Sample.docx", FileFormat.Docx2010);
第 2 步:設(shè)置背景類(lèi)型為圖片。
document.Background.Type = BackgroundType.Picture;
第 3 步:從文件中加載圖像。
document.Background.Picture = Image.FromFile("background.jpg");
第 4 步:將文檔保存到文件中。
document.SaveToFile("Result.docx", FileFormat.Docx2010);
word文檔添加圖片背景的有效截圖:
如何為word文檔設(shè)置圖像背景的完整代碼:
using Spire.Doc; using Spire.Doc.Documents; using System.Drawing; namespace SetImageBackground { class Program { static void Main(string[] args) { { Document document = new Document(); document.LoadFromFile("Sample.docx", FileFormat.Docx2010); document.Background.Type = BackgroundType.Picture; document.Background.Picture = Image.FromFile("background.jpg"); document.SaveToFile("Result.docx", FileFormat.Docx2010); } } } }
歡迎下載|體驗(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@fc6vip.cn