轉帖|使用教程|編輯:黃竹雯|2019-01-08 10:49:12.000|閱讀 743 次
概述:Spire.Doc系列教程之給Word 文檔設置背景顏色和背景圖片。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
使用Spire.Doc,開發人員可以非常方便地給Word文檔設置背景顏色和添加背景圖片。以下示例將詳細講述如何使用Spire.Doc給一個現有Word文檔設置純色背景顏色,漸變背景顏色以及添加背景圖片。
設置純色背景顏色
//創建Document實例 Document document = new Document(); //載入Word文檔 document.LoadFromFile("Input.docx"); //設置文檔的背景填充模式為顏色填充 document.Background.Type = BackgroundType.Color; //設置背景顏色 document.Background.Color = Color.Beige; //保存文檔 document.SaveToFile("PureColor.docx", FileFormat.Docx2013);
設置漸變背景顏色
//創建Document實例 Document document = new Document(); //載入Word文檔 document.LoadFromFile("Input.docx"); //設置文檔的背景填充模式為漸變填充 document.Background.Type = BackgroundType.Gradient; //設置漸變顏色 BackgroundGradient gradient = document.Background.Gradient; gradient.Color1 = Color.White; gradient.Color2 = Color.MediumSeaGreen; //設置漸變模式 gradient.ShadingVariant = GradientShadingVariant.ShadingMiddle; gradient.ShadingStyle = GradientShadingStyle.Horizontal; //保存文檔 document.SaveToFile("GradientColor.docx", FileFormat.Docx2013);
設置背景圖片
//創建Document實例 Document document = new Document(); //載入Word文檔 document.LoadFromFile("Input.docx"); //設置文檔的背景填充模式為圖片填充 document.Background.Type = BackgroundType.Picture; //設置背景圖片 document.Background.Picture = Image.FromFile("background.jpg"); //保存文檔 document.SaveToFile("Image.docx", FileFormat.Docx2013);
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn