文檔半島外圍網上直營>>E-iceblue中文文檔>>為 word 文檔設置圖像背景
                為 word 文檔設置圖像背景
我們已經演示了如何在 C# 中為 word 文檔設置漸變背景。除了漸變背景,Spire.Doc還支持為word文檔添加圖片背景。本文將向您展示如何在 C# 中為 word 文檔設置圖像背景。
第 1 步:創建一個新的 Word 文檔并從文件中加載該文檔。
Document document = new Document();
document.LoadFromFile("Sample.docx", FileFormat.Docx2010);
第 2 步:設置背景類型為圖片。
document.Background.Type = BackgroundType.Picture;
第 3 步:從文件中加載圖像。
document.Background.Picture = Image.FromFile("background.jpg");
第 4 步:將文檔保存到文件中。
document.SaveToFile("Result.docx", FileFormat.Docx2010);
word文檔添加圖片背景的有效截圖:
  
 
如何為word文檔設置圖像背景的完整代碼:
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);
}
}
}
}                
            
 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網安備
            50010702500608號
渝公網安備
            50010702500608號
             
            
 客服熱線
客服熱線