在编辑word文档时,我们会为文档添加艺术字,让文档更美观和具有吸引力。spire.doc里通过shapetype 枚举类型,我们可以添加多种类型的艺术字,并实例化一个shapeobject 来设置艺术字的类型,并添加艺术字内容和设置其样式。该文将详细介绍如何使用spire.doc 创建艺术字并设置样式和效果。
c#
//实例化一个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);
vb.net
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)