翻譯|使用教程|編輯:李顯亮|2019-06-25 09:54:04.903|閱讀 953 次
概述:Spire.Doc支持添加多種形狀(線條,矩形、基本形狀,箭頭,流程圖,公式形狀,星與旗幟及標(biāo)注)等,同時各種單一的形狀也可以組合在一起,成為一組形狀組合。本篇文章介紹了如何將形狀和形狀組合添加到 Word 文檔。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
更多資源查看:Spire.XLS工作表教程 | Spire.Doc系列教程 | Spire.PDF系列教程
Spire.Doc for .NET是一個專業(yè)的Word .NET庫,設(shè)計(jì)用于幫助開發(fā)人員高效地開發(fā)創(chuàng)建、閱讀、編寫、轉(zhuǎn)換和打印任何來自.NET( C#, VB.NET, ASP.NET)平臺的Word文檔文件的功能。
本系列教程將為大家?guī)?strong>Spire.Doc for .NET在使用過程中的各類實(shí)際操作,本篇文章介紹了如何將形狀和形狀組合添加到 Word 文檔。
Spire.Doc支持添加多種形狀(線條,矩形、基本形狀,箭頭,流程圖,公式形狀,星與旗幟及標(biāo)注)等,同時各種單一的形狀也可以組合在一起,成為一組形狀組合。
添加單個形狀
//創(chuàng)建一個Document實(shí)例 Document doc = new Document(); //添加一個section Section sec = doc.AddSection(); //添加一個paragraph Paragraph para1 = sec.AddParagraph(); //插入一個心形 ShapeObject shape1 = para1.AppendShape(50, 50, ShapeType.Heart); shape1.FillColor = Color.Red; shape1.StrokeColor = Color.Red; shape1.HorizontalPosition = 200; shape1.VerticalPosition = 20; //插入一個箭頭 ShapeObject shape2 = para1.AppendShape(100, 100, ShapeType.Arrow); shape2.FillColor = Color.Purple; shape2.StrokeColor = Color.Black; shape2.LineStyle = ShapeLineStyle.Double; shape2.StrokeWeight = 3; shape2.HorizontalPosition = 200; shape2.VerticalPosition = 100; //插入一個公式符號 + ShapeObject shape3 = para1.AppendShape(50, 50, ShapeType.Plus); shape3.FillColor = Color.Red; shape3.StrokeColor = Color.Red; shape3.LineStyle = ShapeLineStyle.Single; shape3.StrokeWeight = 3; shape3.HorizontalPosition = 200; shape3.VerticalPosition = 200; //插入一顆star ShapeObject shape4 = para1.AppendShape(50, 50, ShapeType.Star); shape4.FillColor = Color.Gold; shape4.StrokeColor = Color.Gold; shape4.LineStyle = ShapeLineStyle.Single; shape4.HorizontalPosition = 200; shape4.VerticalPosition = 300; //保存文檔 doc.SaveToFile("InsertShapes.docx", FileFormat.Docx2010);
效果圖:
添加形狀組合
//創(chuàng)建一個Document實(shí)例并添加section及paragraph Document doc = new Document(); Section sec = doc.AddSection(); Paragraph para = sec.AddParagraph(); //創(chuàng)建一個形狀組合并設(shè)置大小 ShapeGroup shapegr = para.AppendShapeGroup(200, 400); //添加一個矩形到形狀組合 shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.Rectangle) { Width = 500, Height = 300, LineStyle = ShapeLineStyle.ThickThin, StrokeColor = System.Drawing.Color.Blue, StrokeWeight = 1.5, }); //添加一個三角形到形狀組合 shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.RightTriangle) { Width = 500, Height = 300, VerticalPosition = 301, LineStyle = ShapeLineStyle.ThickThin, StrokeColor = System.Drawing.Color.Green, StrokeWeight = 1.5, }); //添加一個十字箭頭到形狀組合 shapegr.ChildObjects.Add(new ShapeObject(doc, ShapeType.QuadArrow) { Width = 500, Height = 300, VerticalPosition = 601, LineStyle = ShapeLineStyle.ThickThin, StrokeColor = System.Drawing.Color.Blue, StrokeWeight = 1.5, }); //保存文檔 doc.SaveToFile("InsertShapegroups.docx", FileFormat.Docx2010);
形狀組合效果圖:
*購買Spire.Doc for .NET正版授權(quán)的朋友可以點(diǎn)擊哦~~
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn