How to create fishbowl diagram Aspose word

I want to create a fisbone diagram using Aspose word.
Is it possible?
Thanks

@TECHS,

Please ZIP and attach your expected Word document containing the fishbone diagram here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document by using Microsoft Word. We will then provide you code to achieve the same by using Aspose.Words for .NET.

Fishbone Diagram.jpg (30.5 KB)
5WHYS Diagram.jpg (17.8 KB)

Here’re the samples of 5WHYS & Ishikawa/Fishbone diagrams

Aspose.zip (40.5 KB)

@TECHS,

To insert these images in MS Word document, please use the following code (see output 18.4.zip (43.1 KB)):

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertImage(MyDir + @"5WHYS Diagram.jpg");
builder.InsertImage(MyDir + @"Fishbone Diagram.jpg");            

doc.Save(MyDir + @"18.4.docx");

Sorry for not making clear.
I didn’t have those jpg file yet.
I want to use Aspose word to dynamically create diagram base on the values from database.

@TECHS,

You had just attached image files. But please also ZIP and attach your expected real Word document containing the sample fishbone diagram here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document by using Microsoft Word. We will then provide you code to achieve the same by using Aspose.Words for .NET.

My question was I want to generate a fishbone and 5Whys as shown in attached images.
Can I generate them using Aspose Word?

It didn’t let me upload docx but image file only

@TECHS,

Thanks for your inquiry. Please ZIP and upload your Words document here for testing. We will investigate the issue on our end and provide you more information.

TestFiles.zip (50.8 KB)

@TECHS,

You can create different types of Shapes by using Aspose.Words and then make them part of a single GroupShape object. Please see the following sample code:

Document doc = new Document(MyDir + @"input.docx");

Shape s1 = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.TextPlainText, new RectangleF(72, 72, 72, 72), "hello");
Shape s2 = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.Line, new RectangleF(144, 144, 72, 0), "");
Shape s3 = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.DownArrow, new RectangleF(144, 144, 36, 144), "");

GroupShape gs = new GroupShape(doc);
gs.Width = 72 * 4;
gs.Height = 72 * 4;
gs.CoordSize = new System.Drawing.Size(72 * 4, 72 * 4);

gs.AppendChild(s1);
gs.AppendChild(s2);
gs.AppendChild(s3);

DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
builder.Writeln();
builder.Writeln();
builder.Writeln();
builder.InsertNode(gs);

doc.Save(MyDir + @"18.4.docx");

public static Shape AddShape(Document doc, Paragraph anchorPara, ShapeType shapeType, RectangleF rectangleF, string text)
{
    Shape shape = new Shape(doc, shapeType);

    shape.Left = rectangleF.Left;
    shape.Top = rectangleF.Top;
    shape.Width = rectangleF.Width;
    shape.Height = rectangleF.Height;

    shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
    shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
    shape.WrapType = WrapType.None;

    if (!string.IsNullOrEmpty(text))
    {
        Paragraph para = new Paragraph(doc);
        Run run = new Run(doc, text);
        para.AppendChild(run);
        shape.AppendChild(para);
    }


    anchorPara.AppendChild(shape);

    return shape;
}

Can you send me VB codes?
I tried to convert them to VB and got AddShape underfined error.

Dim s1 As Shape = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.TextPlainText, New RectangleF(72, 72, 72, 72), “hello”)
Dim s2 As Shape = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.Line, New RectangleF(144, 144, 72, 0), “”)
Dim s3 As Shape = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.DownArrow, New RectangleF(144, 144, 36, 144), “”)

@TECHS,

We are working over your query and will get back to you soon.

@TECHS,

The VB.NET code would be like this:

Dim doc As New Document(MyDir & "input.docx")

Dim s1 As Shape = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.TextPlainText, New RectangleF(72, 72, 72, 72), "hello")
Dim s2 As Shape = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.Line, New RectangleF(144, 144, 72, 0), "")
Dim s3 As Shape = AddShape(doc, doc.FirstSection.Body.FirstParagraph, ShapeType.DownArrow, New RectangleF(144, 144, 36, 144), "")

Dim gs As New GroupShape(doc)
gs.Width = 72 * 4
gs.Height = 72 * 4
gs.CoordSize = New System.Drawing.Size(72 * 4, 72 * 4)

gs.AppendChild(s1)
gs.AppendChild(s2)
gs.AppendChild(s3)

Dim builder As New DocumentBuilder(doc)
builder.MoveToDocumentEnd()
builder.Writeln()
builder.Writeln()
builder.Writeln()
builder.InsertNode(gs)

doc.Save(MyDir & "vb.docx")
/////////////////////////////////////////////
Public Function AddShape(ByVal doc As Document, ByVal anchorPara As Paragraph, ByVal shapeType As ShapeType, ByVal rectangleF As RectangleF, ByVal text As String) As Shape
    Dim shape As Shape = New Shape(doc, shapeType)
    shape.Left = rectangleF.Left
    shape.Top = rectangleF.Top
    shape.Width = rectangleF.Width
    shape.Height = rectangleF.Height
    shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page
    shape.RelativeVerticalPosition = RelativeVerticalPosition.Page
    shape.WrapType = WrapType.None
    If Not String.IsNullOrEmpty(text) Then
        Dim para As Paragraph = New Paragraph(doc)
        Dim run As Run = New Run(doc, text)
        para.AppendChild(run)
        shape.AppendChild(para)
    End If

    anchorPara.AppendChild(shape)
    Return shape
End Function 

Hope, this helps.