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