如何在 Word 文檔中加入 Group 形狀
Contents
[
Hide
]
有時你需要在一個 Word 文檔中加上一個 group shape。 這樣的 group shape 包含多個圖形。
在Microsoft Word中,您可以用Group命令/按鈕快速加上一個group shape。 一組中的獨立形狀可以分開移動。
在 Aspose.Words 中,使用 GroupShape 類別非常容易加入 group shape。 Shape 透過 Shape 類別獨立建立,然後透過 AppendChild 方法加入 GroupShape 物件。
以下範例展示如何在 Word 文檔中加入 group shape:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_WorkingWithDocument(); | |
Document doc = new Document(); | |
doc.EnsureMinimum(); | |
GroupShape gs = new GroupShape(doc); | |
Shape shape = new Shape(doc, Drawing.ShapeType.AccentBorderCallout1); | |
shape.Width = 100; | |
shape.Height = 100; | |
gs.AppendChild(shape); | |
Shape shape1 = new Shape(doc, Drawing.ShapeType.ActionButtonBeginning); | |
shape1.Left = 100; | |
shape1.Width = 100; | |
shape1.Height = 200; | |
gs.AppendChild(shape1); | |
gs.Width = 200; | |
gs.Height = 200; | |
gs.CoordSize = new System.Drawing.Size(200, 200); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
builder.InsertNode(gs); | |
dataDir = dataDir + "groupshape-doc_out.doc"; | |
// Save the document to disk. | |
doc.Save(dataDir); |
以下是一些 Shape
類型在 Aspose.Words 中支援的:
-矩形
- RoundRectangle “- RoundRectangle”
- 椭圓
- 鑽石 “- 三角形”
- 直角三角形 -平行四邊形 “- 梯形” “- 六角”
- 八角形
完整清單請見 ShapeType 班級。