轉帖|使用教程|編輯:黃竹雯|2019-01-31 15:18:29.000|閱讀 1119 次
概述:Spire.Doc系列教程之在Word中設置文字效果。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文將介紹如何使用Spire.Doc來設置文字效果,包括文本邊框,文本填充,文字陰影等。
//實例化一個Document對象 Document doc = new Document(); //向文檔中添加一個Section對象 Section sec = doc.AddSection(); //在這個section上添加一個段落并給文字加邊框 Paragraph p1 = sec.AddParagraph(); TextRange tr1 = p1.AppendText("加粉色邊框的文字"); tr1.CharacterFormat.Border.BorderType = BorderStyle.DashDotStroker; tr1.CharacterFormat.Border.Color = Color.Pink; p1.AppendBreak(BreakType.LineBreak); //添加一個新段落并設置文字填充效果 Paragraph p2 = sec.AddParagraph(); TextRange tr2 = p2.AppendText("設置填充效果的文字"); //設置文字前景色 tr2.CharacterFormat.TextColor = Color.Orange; //設置文字背景色 tr2.CharacterFormat.TextBackgroundColor = Color.LightGray; //設置文字縮放比例 tr2.CharacterFormat.TextScale = 150; p2.AppendBreak(BreakType.LineBreak); //添加一個新段落并設置陰影 Paragraph p3 = sec.AddParagraph(); TextRange tr3 = p3.AppendText("設置陰影效果的文字"); tr3.CharacterFormat.TextColor = Color.LightSeaGreen; tr3.CharacterFormat.IsShadow = true; p3.AppendBreak(BreakType.LineBreak); //添加一個新段落并設置簡單的文字樣式 Paragraph p4 = sec.AddParagraph(); TextRange tr4 = p4.AppendText("設置刪除線效果的文字"); tr4.CharacterFormat.IsStrikeout = true; p4.AppendBreak(BreakType.LineBreak); TextRange tr5 = p4.AppendText("設置文字大寫: hello, e-iceblue."); tr5.CharacterFormat.IsSmallCaps = true; //使用ClearFormatting()來刪除某個TextRange的文字效果 //tr5.CharacterFormat.ClearFormatting(); //保存文檔 doc.SaveToFile("文字效果.docx");
效果圖如下:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn