在編輯word文檔時,咱們會爲文檔添加藝術字,讓文檔更美觀和具備吸引力。Spire.Doc裏經過ShapeType枚舉類型,咱們能夠添加多種類型的藝術字,並實例化一個ShapeObject來設置藝術字的類型,並添加藝術字內容和設置其樣式。 本文將詳細介紹如何使用Spire.Doc建立藝術字並設置樣式和效果。html
【下載Spire.Doc最新試用版】bash
//實例化一個word Document並添加一個section和段落
Document doc = new Document();
Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();
//添加一個Shape,並設置其大小和樣式
ShapeObject shape = paragraph.AppendShape(240, 60, ShapeType.TextWave);
//設置shape的位置
shape.VerticalPosition = 80;
shape.HorizontalPosition = 100;
//寫入藝術字文本和設置斜體
shape.WordArt.Text = "藝術字效果";
shape.WordArt.Italic = true;
//設置文字填充樣式
shape.FillColor = System.Drawing.Color.Red;
shape.StrokeColor = System.Drawing.Color.Gray;
//保存文檔
doc.SaveToFile("Output.docx", FileFormat.Docx2013); 複製代碼
Dim doc As New Document()
Dim section As Section = doc.AddSection()
Dim paragraph As Paragraph = section.AddParagraph()
Dim shape As ShapeObject = paragraph.AppendShape(240, 60, ShapeType.TextWave)
shape.VerticalPosition = 80
shape.HorizontalPosition = 100
shape.WordArt.Text = "藝術字效果"
shape.WordArt.Italic = True
shape.FillColor = System.Drawing.Color.Red
shape.StrokeColor = System.Drawing.Color.Gray
doc.SaveToFile("Output.docx", FileFormat.Docx2013)複製代碼
效果圖:
spa
想看冰藍更多產品教程嗎?爲你推薦:code