Grup Şekli Ekle

Bu eğitimde Aspose.Words for .NET kullanılarak birden fazla şekil içeren bir grup şeklinin bir Word belgesine nasıl ekleneceği açıklanmaktadır. Grup şekilleri, birden çok şekli tek bir varlık olarak birleştirmenize ve değiştirmenize olanak tanır.

Önkoşullar

Bu öğreticiyi takip etmek için aşağıdakilere sahip olmanız gerekir:

  • Aspose.Words for .NET kütüphanesi kuruldu.
  • Temel C# bilgisi ve Word belgeleriyle Kelime İşleme.

1. Adım: Belge Dizinini Ayarlayın

Belge dizininizin yolunu ayarlayarak başlayın. Yer değiştirmek"YOUR DOCUMENT DIRECTORY" belgeyi kaydetmek istediğiniz dizinin gerçek yolu ile birlikte.

string dataDir = "YOUR DOCUMENT DIRECTORY";

Adım 2: Yeni Bir Belge ve GroupShape Oluşturun

Yeni bir örneğini oluşturunDocument sınıf veGroupShape belgeyle çalışmaya itiraz edin.

Document doc = new Document();
doc.EnsureMinimum();
GroupShape groupShape = new GroupShape(doc);

Adım 3: GroupShape’e Şekiller Oluşturun ve Ekleyin

Gibi bireysel şekiller oluşturunaccentBorderShape VeactionButtonShape kullanmakShape sınıf. Özelliklerini istediğiniz gibi özelleştirin. Bu şekilleri şuraya ekleyin:groupShape nesne.

Shape accentBorderShape = new Shape(doc, ShapeType.AccentBorderCallout1) { Width = 100, Height = 100 };
groupShape.AppendChild(accentBorderShape);

Shape actionButtonShape = new Shape(doc, ShapeType.ActionButtonBeginning)
{
    Left = 100,
    Width = 100,
    Height = 200
};
groupShape.AppendChild(actionButtonShape);

Adım 4: GroupShape için Boyutları Ayarlayın

Genişliği, yüksekliği ve koordinat boyutunu ayarlayın.groupShape.

groupShape.Width = 200;
groupShape.Height = 200;
groupShape.CoordSize = new Size(200, 200);

Adım 5: GroupShape’i Belgeye Ekleme

OluşturmakDocumentBuilder nesneyi ekleyin vegroupShape kullanarak belgeye ekleyin.InsertNode yöntem.

DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertNode(groupShape);

Adım 6: Belgeyi Kaydedin

Belgeyi kullanarak belirtilen dizine kaydedin.Saveyöntem. İstediğiniz dosya adını uygun dosya uzantısıyla sağlayın. Bu örnekte belgeyi “WorkingWithShapes.AddGroupShape.docx” olarak kaydediyoruz.

doc.Save(dataDir + "WorkingWithShapes.AddGroupShape.docx");

Aspose.Words for .NET kullanarak Grup Şekli Ekleme için örnek kaynak kodu

	// Belge dizininizin yolu
	string dataDir = "YOUR DOCUMENT DIRECTORY";

	Document doc = new Document();
	doc.EnsureMinimum();
	GroupShape groupShape = new GroupShape(doc);
	Shape accentBorderShape = new Shape(doc, ShapeType.AccentBorderCallout1) { Width = 100, Height = 100 };
	groupShape.AppendChild(accentBorderShape);
	Shape actionButtonShape = new Shape(doc, ShapeType.ActionButtonBeginning)
	{
		Left = 100, Width = 100, Height = 200
	};
	groupShape.AppendChild(actionButtonShape);
	groupShape.Width = 200;
	groupShape.Height = 200;
	groupShape.CoordSize = new Size(200, 200);
	DocumentBuilder builder = new DocumentBuilder(doc);
	builder.InsertNode(groupShape);
	doc.Save(dataDir + "WorkingWithShapes.AddGroupShape.docx");

Bu kadar! Aspose.W kullanarak Word belgenize birden fazla şekil içeren bir grup şeklini başarıyla eklediniz.