การทำงานกับรูปร่าง Group ในเอกสาร Word
บางครั้งคุณจำเป็นต้องเพิ่ม group shape ลงในเอกสาร Word group shape ดังกล่าวประกอบด้วยหลายรูปร่าง
ใน Microsoft Word คุณสามารถเพิ่ม group shape ได้อย่างรวดเร็วโดยใช้คำสั่ง/ปุ่ม Group แต่ละรูปร่างในกลุ่มสามารถย้ายแยกกันได้
ใน Aspose.Words การเพิ่ม group shape โดยใช้คลาส GroupShape ทำได้ง่ายมาก รูปร่างถูกสร้างขึ้นแยกกันโดยใช้คลาส Shape จากนั้นเพิ่มในออบเจ็กต์ GroupShape โดยใช้วิธี append_child
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีเพิ่ม group shape ลงในเอกสาร Word:
# For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Python-via-.NET | |
doc = aw.Document() | |
doc.ensure_minimum() | |
groupShape = aw.drawing.GroupShape(doc) | |
accentBorderShape = aw.drawing.Shape(doc, aw.drawing.ShapeType.ACCENT_BORDER_CALLOUT1) | |
accentBorderShape.width = 100 | |
accentBorderShape.height = 100 | |
groupShape.append_child(accentBorderShape) | |
actionButtonShape = aw.drawing.Shape(doc, aw.drawing.ShapeType.ACTION_BUTTON_BEGINNING) | |
actionButtonShape.left = 100 | |
actionButtonShape.width = 100 | |
actionButtonShape.height = 200 | |
groupShape.append_child(actionButtonShape) | |
groupShape.width = 200 | |
groupShape.height = 200 | |
groupShape.coord_size = drawing.Size(200, 200) | |
builder = aw.DocumentBuilder(doc) | |
builder.insert_node(groupShape) | |
doc.save(docs_base.artifacts_dir + "WorkingWithShapes.add_group_shape.docx") |
ด้านล่างนี้คือ Shape
บางประเภทที่รองรับใน Aspose.Words สำหรับรายการทั้งหมด โปรดดูการแจงนับ aspose.words.drawing.ShapeType