Free Support Forum - aspose.com

Create a down arrow 45 degree angle

I tried to create the 45 degree down arrow but couldn’t.
Please let me know if you can help.
Please see attachment
Example.jpg (8.8 KB)

@TECHS,

Thanks for your inquiry. The ShapeBase.Rotation property defines the angle (in degrees) that a shape is rotated. Positive value corresponds to clockwise rotation angle. Please check the following code example. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
                  
Shape arrow = new Shape(doc, ShapeType.Arrow);
arrow.Height = 20;
arrow.Width = 100;
arrow.Rotation = 45;
arrow.StrokeColor = Color.Red;
builder.InsertNode(arrow);

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

I modified your codes to get the arrow as attached.
However, how can I create 3 same paralleled arrows with a straight arrow at the bottom.

Thanks for your help.Example2.jpg (44.6 KB)

@TECHS,

Thanks for your inquiry. We suggest you please read the members of Shape class. Please check the following code example. Hope this helps you.

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

Shape arrow = new Shape(doc, ShapeType.Arrow);
arrow.Left = 0;
arrow.Height = 20;
arrow.Width = 100;
arrow.Rotation = 45;
arrow.StrokeColor = Color.Red;
builder.InsertNode(arrow);

Shape arrow2 = new Shape(doc, ShapeType.Arrow);
arrow2.Left = 50;
arrow2.Height = 20;
arrow2.Width = 100;
arrow2.Rotation = 45;
arrow2.StrokeColor = Color.Red;
builder.InsertNode(arrow2);

Shape arrow3 = new Shape(doc, ShapeType.Arrow);
arrow3.Left = 100;
arrow3.Height = 20;
arrow3.Width = 100;
arrow3.Rotation = 45;
arrow3.StrokeColor = Color.Red;
builder.InsertNode(arrow3);

Shape arrow4 = new Shape(doc, ShapeType.Arrow);
arrow4.Top = 50;
arrow4.Left = 0;
arrow4.Height = 20;
arrow4.Width = 200;
arrow4.StrokeColor = Color.Red;
builder.InsertNode(arrow4);

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

I added a textbox with long text inside but I can’t get it to work properly. I can’t set textbox width.MyOutput.zip (31.5 KB)

Attached are 2 files: one is my expected file and one is actual output.

Private Sub CreateDownarrowMethod()
Dim requestId As String = “1383528”
Dim filePathName As String = “C:\Aspose\Files\FRB\inMyFileDOC.docx”

    Dim doc As New Aspose.Words.Document(filePathName)
    Dim docBuilder As DocumentBuilder = New DocumentBuilder(doc)

    docBuilder.Font.Size = 6
    docBuilder.MoveToDocumentEnd()
    docBuilder.Font.Size = "6"
    docBuilder.Font.Name = "Arial"
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim man As Shape = GetTextBox(docBuilder, 20, -40, 100, 20)
    Dim manPara As New Paragraph(doc)
    manPara.AppendChild(New Run(doc, "MAN"))
    man.AppendChild(manPara)
    docBuilder.InsertNode(man)

    Dim manCauseTxt As String
    manCauseTxt = "Operator understands the standards? Yes" _
                    + " Operator understands quality outcomes? Yes()" _
                    + " Job done the same on all shifts? Yes()" _
                    + " Operator trained properly? Yes" _
                    + " Operator followed the instructions? NO" _
                    + " Parts were blocked at previsous claim? NO"

    Dim manCause As Shape = GetTextBox(docBuilder, 5, -40, 10, 50)
    Dim manCausePara As New Paragraph(doc)
    manCausePara.AppendChild(New Run(doc, manCauseTxt))
    manCause.AppendChild(manCausePara)
    docBuilder.InsertNode(manCause)

    Dim method As Shape = GetTextBox(docBuilder, 167, -40, 100, 20)
    Dim methodPara As New Paragraph(doc)
    methodPara.AppendChild(New Run(doc, "METHOD"))
    method.AppendChild(methodPara)
    docBuilder.InsertNode(method)

    Dim machine As Shape = GetTextBox(docBuilder, 320, -40, 100, 20)
    Dim machinePara As New Paragraph(doc)
    machinePara.AppendChild(New Run(doc, "MACHINE"))
    machine.AppendChild(machinePara)
    docBuilder.InsertNode(machine)

    Dim material As Shape = GetTextBox(docBuilder, 15, 400, 100, 20)
    Dim materialPara As New Paragraph(doc)
    materialPara.AppendChild(New Run(doc, "MATERIAL"))
    material.AppendChild(materialPara)
    docBuilder.InsertNode(material)

    Dim measurement As Shape = GetTextBox(docBuilder, 155, 400, 100, 20)
    Dim measurementPara As New Paragraph(doc)
    measurementPara.AppendChild(New Run(doc, "MEASUREMENT"))
    measurement.AppendChild(measurementPara)
    docBuilder.InsertNode(measurement)

    Dim environment As Shape = GetTextBox(docBuilder, 330, 400, 100, 20)
    Dim environmentPara As New Paragraph(doc)
    environmentPara.AppendChild(New Run(doc, "ENVIRONMENT"))
    environment.AppendChild(environmentPara)
    docBuilder.InsertNode(environment)


    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim arrowMan As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMan.Top = 40
    arrowMan.Left = -10
    arrowMan.Width = 250
    arrowMan.Height = 3
    arrowMan.Rotation = 80
    arrowMan.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMan.StrokeColor = System.Drawing.Color.Black
    arrowMan.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMan)

    Dim arrowMethod As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMethod.Top = 40
    arrowMethod.Left = 140
    arrowMethod.Width = 250
    arrowMethod.Height = 3
    arrowMethod.Rotation = 80
    arrowMethod.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMethod.StrokeColor = System.Drawing.Color.Black
    arrowMethod.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMethod)

    Dim arrowMachine As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMachine.Top = 40
    arrowMachine.Left = 290
    arrowMachine.Width = 250
    arrowMachine.Height = 3
    arrowMachine.Rotation = 80
    arrowMachine.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMachine.StrokeColor = System.Drawing.Color.Black
    arrowMachine.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMachine)


    Dim mainArrow As Shape = New Shape(doc, ShapeType.Arrow)
    mainArrow.Top = 155
    mainArrow.Left = 0
    mainArrow.Width = 520
    mainArrow.Height = 3
    mainArrow.StrokeWeight = System.Drawing.FontStyle.Bold
    mainArrow.StrokeColor = System.Drawing.Color.Black
    mainArrow.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(mainArrow)

    Dim arrowMaterial As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMaterial.Top = 260
    arrowMaterial.Left = -10
    arrowMaterial.Width = 250
    arrowMaterial.Height = 3
    arrowMaterial.Rotation = -80
    arrowMaterial.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMaterial.StrokeColor = System.Drawing.Color.Black
    arrowMaterial.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMaterial)

    Dim arrowMeasurement As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMeasurement.Top = 260
    arrowMeasurement.Left = 140
    arrowMeasurement.Width = 250
    arrowMeasurement.Height = 3
    arrowMeasurement.Rotation = -80
    arrowMeasurement.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMeasurement.StrokeColor = System.Drawing.Color.Black
    arrowMeasurement.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMeasurement)

    Dim arrowEnvironment As Shape = New Shape(doc, ShapeType.Arrow)
    arrowEnvironment.Top = 260
    arrowEnvironment.Left = 290
    arrowEnvironment.Width = 250
    arrowEnvironment.Height = 3
    arrowEnvironment.Rotation = -80
    arrowEnvironment.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowEnvironment.StrokeColor = System.Drawing.Color.Black
    arrowEnvironment.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowEnvironment)

    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    doc.Save("C:\\Aspose\\Files\\FRB\\outMyFileDOC.docx")

End Sub

Private Shared Function GetTextBox(ByVal builder As DocumentBuilder, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Shape
    Dim txt As New Aspose.Words.Drawing.Shape(builder.Document, ShapeType.TextBox)
    txt.Left = x
    txt.Top = y
    txt.WrapType = WrapType.None
    txt.TextBox.TextBoxWrapMode = TextBoxWrapMode.None
    txt.TextBox.FitShapeToText = True
    txt.Width = width
    txt.Height = height
    txt.AllowOverlap = True
    Return txt
End Function

@TECHS,

Thanks for your inquiry. Please ZIP and attach your input word document along with code of GetTextBox method. We will investigate this issue and provide you more information on it along with code.

Private Sub CreateDownarrowMethod()
MyOutput.zip (31.5 KB)

    Dim filePathName As String = "C:\\Aspose\\Files\\FRB\\inMyFileDOC.docx"

    Dim doc As New Aspose.Words.Document(filePathName)
    Dim docBuilder As DocumentBuilder = New DocumentBuilder(doc)

    docBuilder.Font.Size = 6
    docBuilder.MoveToDocumentEnd()
    docBuilder.Font.Size = "6"
    docBuilder.Font.Name = "Arial"
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim man As Shape = GetTextBox(docBuilder, 20, -40, 100, 20)
    Dim manPara As New Paragraph(doc)
    manPara.AppendChild(New Run(doc, "MAN"))
    man.AppendChild(manPara)
    docBuilder.InsertNode(man)

    Dim manCauseTxt As String
    manCauseTxt = "Operator understands the standards? Yes" _
                    + " Operator understands quality outcomes? Yes()" _
                    + " Job done the same on all shifts? Yes()" _
                    + " Operator trained properly? Yes" _
                    + " Operator followed the instructions? NO" _
                    + " Parts were blocked at previsous claim? NO"

    Dim manCause As Shape = GetTextBox(docBuilder, 5, -40, 10, 50)
    Dim manCausePara As New Paragraph(doc)
    manCausePara.AppendChild(New Run(doc, manCauseTxt))
    manCause.AppendChild(manCausePara)
    docBuilder.InsertNode(manCause)

    Dim method As Shape = GetTextBox(docBuilder, 167, -40, 100, 20)
    Dim methodPara As New Paragraph(doc)
    methodPara.AppendChild(New Run(doc, "METHOD"))
    method.AppendChild(methodPara)
    docBuilder.InsertNode(method)

    Dim machine As Shape = GetTextBox(docBuilder, 320, -40, 100, 20)
    Dim machinePara As New Paragraph(doc)
    machinePara.AppendChild(New Run(doc, "MACHINE"))
    machine.AppendChild(machinePara)
    docBuilder.InsertNode(machine)

    Dim material As Shape = GetTextBox(docBuilder, 15, 400, 100, 20)
    Dim materialPara As New Paragraph(doc)
    materialPara.AppendChild(New Run(doc, "MATERIAL"))
    material.AppendChild(materialPara)
    docBuilder.InsertNode(material)

    Dim measurement As Shape = GetTextBox(docBuilder, 155, 400, 100, 20)
    Dim measurementPara As New Paragraph(doc)
    measurementPara.AppendChild(New Run(doc, "MEASUREMENT"))
    measurement.AppendChild(measurementPara)
    docBuilder.InsertNode(measurement)

    Dim environment As Shape = GetTextBox(docBuilder, 330, 400, 100, 20)
    Dim environmentPara As New Paragraph(doc)
    environmentPara.AppendChild(New Run(doc, "ENVIRONMENT"))
    environment.AppendChild(environmentPara)
    docBuilder.InsertNode(environment)


    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim arrowMan As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMan.Top = 40
    arrowMan.Left = -10
    arrowMan.Width = 250
    arrowMan.Height = 3
    arrowMan.Rotation = 80
    arrowMan.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMan.StrokeColor = System.Drawing.Color.Black
    arrowMan.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMan)

    Dim arrowMethod As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMethod.Top = 40
    arrowMethod.Left = 140
    arrowMethod.Width = 250
    arrowMethod.Height = 3
    arrowMethod.Rotation = 80
    arrowMethod.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMethod.StrokeColor = System.Drawing.Color.Black
    arrowMethod.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMethod)

    Dim arrowMachine As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMachine.Top = 40
    arrowMachine.Left = 290
    arrowMachine.Width = 250
    arrowMachine.Height = 3
    arrowMachine.Rotation = 80
    arrowMachine.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMachine.StrokeColor = System.Drawing.Color.Black
    arrowMachine.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMachine)


    Dim mainArrow As Shape = New Shape(doc, ShapeType.Arrow)
    mainArrow.Top = 155
    mainArrow.Left = 0
    mainArrow.Width = 520
    mainArrow.Height = 3
    mainArrow.StrokeWeight = System.Drawing.FontStyle.Bold
    mainArrow.StrokeColor = System.Drawing.Color.Black
    mainArrow.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(mainArrow)

    Dim arrowMaterial As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMaterial.Top = 260
    arrowMaterial.Left = -10
    arrowMaterial.Width = 250
    arrowMaterial.Height = 3
    arrowMaterial.Rotation = -80
    arrowMaterial.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMaterial.StrokeColor = System.Drawing.Color.Black
    arrowMaterial.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMaterial)

    Dim arrowMeasurement As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMeasurement.Top = 260
    arrowMeasurement.Left = 140
    arrowMeasurement.Width = 250
    arrowMeasurement.Height = 3
    arrowMeasurement.Rotation = -80
    arrowMeasurement.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMeasurement.StrokeColor = System.Drawing.Color.Black
    arrowMeasurement.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMeasurement)

    Dim arrowEnvironment As Shape = New Shape(doc, ShapeType.Arrow)
    arrowEnvironment.Top = 260
    arrowEnvironment.Left = 290
    arrowEnvironment.Width = 250
    arrowEnvironment.Height = 3
    arrowEnvironment.Rotation = -80
    arrowEnvironment.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowEnvironment.StrokeColor = System.Drawing.Color.Black
    arrowEnvironment.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowEnvironment)

    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    doc.Save("C:\\Aspose\\Files\\FRB\\outMyFileDOC.docx")

End Sub

Private Shared Function GetTextBox(ByVal builder As DocumentBuilder, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Shape
    Dim txt As New Aspose.Words.Drawing.Shape(builder.Document, ShapeType.TextBox)
    txt.Left = x
    txt.Top = y
    txt.WrapType = WrapType.None
    txt.TextBox.TextBoxWrapMode = TextBoxWrapMode.None
    txt.TextBox.FitShapeToText = True
    txt.Width = width
    txt.Height = height
    txt.AllowOverlap = True
    Return txt
End Function

MyOutput.zip (31.5 KB)

@TECHS,

Thanks for your inquiry. Please remove following line of code from GetTextBox method.

txt.TextBox.TextBoxWrapMode = TextBoxWrapMode.None

Private Shared Function GetTextBox(ByVal builder As DocumentBuilder, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Shape
    Dim txt As New Aspose.Words.Drawing.Shape(builder.Document, ShapeType.TextBox)
    txt.Left = x
    txt.Top = y
    txt.WrapType = WrapType.None
    
    txt.TextBox.FitShapeToText = True
    txt.Width = width
    txt.Height = height
    txt.AllowOverlap = True
    Return txt
End Function

Please replace following line of code
Dim manCause As Shape = GetTextBox(docBuilder, 5, -40, 10, 50)

with

Dim manCause As Shape = GetTextBox(docBuilder, -30, 7.2, 126, 190)

in your code to get the desired output.

There’re 3 textboxes with different length of text.
How can I know which position I can write the 2nd box, 3rd box.

MyTestFiles.zip (17.1 KB)

Dim filePathName As String = “C:\Aspose\Files\FRB\inMyFileDOC.docx”

    Dim doc As New Aspose.Words.Document(filePathName)
    Dim docBuilder As DocumentBuilder = New DocumentBuilder(doc)

    docBuilder.Font.Size = 6
    docBuilder.MoveToDocumentEnd()
    docBuilder.Font.Size = FontSize.XXSmall
    docBuilder.Font.Name = "Arial"
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim man As Shape = GetTextBox2(docBuilder, 25, -40, 100, 20)
    Dim manPara As New Paragraph(doc)
    manPara.AppendChild(New Run(doc, "MAN"))
    man.AppendChild(manPara)
    docBuilder.InsertNode(man)

    Dim manCauseTxt As String
    manCauseTxt = "Basic qualification of the employee [Excluded as Cause]"

    Dim manCause As Shape = GetTextBox(docBuilder, -30, 5.2, 126, 190)
    Dim manCausePara As New Paragraph(doc)
    manCausePara.AppendChild(New Run(doc, manCauseTxt))
    manCause.AppendChild(manCausePara)
    docBuilder.InsertNode(manCause)

    manCauseTxt = "Inattention of the sorting worker [Confirmed as Cause ]"

    Dim manCause2 As Shape = GetTextBox(docBuilder, -40, 10.2, 126, 190)
    Dim manCausePara2 As New Paragraph(doc)
    manCausePara2.AppendChild(New Run(doc, manCauseTxt))
    manCause2.AppendChild(manCausePara2)
    docBuilder.InsertNode(manCause2)

    manCauseTxt = "Lack of experience and Training [Possible Cause]"

    Dim manCause3 As Shape = GetTextBox(docBuilder, -50, 15.2, 126, 190)
    Dim manCausePara3 As New Paragraph(doc)
    manCausePara3.AppendChild(New Run(doc, manCauseTxt))
    manCause3.AppendChild(manCausePara3)
    docBuilder.InsertNode(manCause3)

    Dim method As Shape = GetTextBox2(docBuilder, 167, -40, 100, 20)
    Dim methodPara As New Paragraph(doc)
    methodPara.AppendChild(New Run(doc, "METHOD"))
    method.AppendChild(methodPara)
    docBuilder.InsertNode(method)

    Dim machine As Shape = GetTextBox2(docBuilder, 320, -40, 100, 20)
    Dim machinePara As New Paragraph(doc)
    machinePara.AppendChild(New Run(doc, "MACHINE"))
    machine.AppendChild(machinePara)
    docBuilder.InsertNode(machine)

    Dim material As Shape = GetTextBox2(docBuilder, 15, 400, 100, 20)
    Dim materialPara As New Paragraph(doc)
    materialPara.AppendChild(New Run(doc, "MATERIAL"))
    material.AppendChild(materialPara)
    docBuilder.InsertNode(material)

    Dim measurement As Shape = GetTextBox2(docBuilder, 155, 400, 100, 20)
    Dim measurementPara As New Paragraph(doc)
    measurementPara.AppendChild(New Run(doc, "MEASUREMENT"))
    measurement.AppendChild(measurementPara)
    docBuilder.InsertNode(measurement)

    Dim environment As Shape = GetTextBox(docBuilder, 330, 400, 100, 20)
    Dim environmentPara As New Paragraph(doc)
    environmentPara.AppendChild(New Run(doc, "ENVIRONMENT"))
    environment.AppendChild(environmentPara)
    docBuilder.InsertNode(environment)


    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim arrowMan As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMan.Top = 40
    arrowMan.Left = -10
    arrowMan.Width = 250
    arrowMan.Height = 3
    arrowMan.Rotation = 80
    arrowMan.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMan.StrokeColor = System.Drawing.Color.Black
    arrowMan.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMan)

    Dim arrowMethod As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMethod.Top = 40
    arrowMethod.Left = 140
    arrowMethod.Width = 250
    arrowMethod.Height = 3
    arrowMethod.Rotation = 80
    arrowMethod.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMethod.StrokeColor = System.Drawing.Color.Black
    arrowMethod.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMethod)

    Dim arrowMachine As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMachine.Top = 40
    arrowMachine.Left = 290
    arrowMachine.Width = 250
    arrowMachine.Height = 3
    arrowMachine.Rotation = 80
    arrowMachine.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMachine.StrokeColor = System.Drawing.Color.Black
    arrowMachine.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMachine)


    Dim mainArrow As Shape = New Shape(doc, ShapeType.Arrow)
    mainArrow.Top = 155
    mainArrow.Left = 0
    mainArrow.Width = 520
    mainArrow.Height = 3
    mainArrow.StrokeWeight = System.Drawing.FontStyle.Bold
    mainArrow.StrokeColor = System.Drawing.Color.Black
    mainArrow.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(mainArrow)

    Dim arrowMaterial As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMaterial.Top = 260
    arrowMaterial.Left = -10
    arrowMaterial.Width = 250
    arrowMaterial.Height = 3
    arrowMaterial.Rotation = -80
    arrowMaterial.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMaterial.StrokeColor = System.Drawing.Color.Black
    arrowMaterial.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMaterial)

    Dim arrowMeasurement As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMeasurement.Top = 260
    arrowMeasurement.Left = 140
    arrowMeasurement.Width = 250
    arrowMeasurement.Height = 3
    arrowMeasurement.Rotation = -80
    arrowMeasurement.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMeasurement.StrokeColor = System.Drawing.Color.Black
    arrowMeasurement.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMeasurement)

    Dim arrowEnvironment As Shape = New Shape(doc, ShapeType.Arrow)
    arrowEnvironment.Top = 260
    arrowEnvironment.Left = 290
    arrowEnvironment.Width = 250
    arrowEnvironment.Height = 3
    arrowEnvironment.Rotation = -80
    arrowEnvironment.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowEnvironment.StrokeColor = System.Drawing.Color.Black
    arrowEnvironment.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowEnvironment)

    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    doc.Save("C:\\Aspose\\Files\\FRB\\outMyFileDOC.docx")<a class="attachment" href="/uploads/discourse_instance3/14427">outMyFileDOC.zip</a> (9.8 KB)

@TECHS,

Thanks for your inquiry. In your case, we suggest you following solution.

  1. Insert the bookmark at the end of text in the textboxes.

  2. Get the position of bookmark using layout API. Please check the code snippet below.

  3. Set the Shape.Top property according to bookmark’s position.

    Dim collector As LayoutCollector = New LayoutCollector(doc)
    Dim enumerator As LayoutEnumerator = New LayoutEnumerator(doc)
    Dim bStart As BookmarkStart = doc.Range.Bookmarks(“bookmark”).BookmarkStart
    enumerator.Current = collector.GetEntity(bStart)
    Console.WriteLine(enumerator.Rectangle.Top)

I did insert bookmark and follow your instructions but I still couldn’t get it work.outMyFileDOC.zip (7.4 KB)

Dim filePathName As String = “C:\Aspose\Files\FRB\inMyFileDOC.docx”

    Dim doc As New Aspose.Words.Document(filePathName)
    Dim docBuilder As DocumentBuilder = New DocumentBuilder(doc)

    docBuilder.Font.Size = 6
    docBuilder.MoveToDocumentEnd()
    docBuilder.Font.Size = FontSize.XXSmall
    docBuilder.Font.Name = "Arial"
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim man As Shape = GetTextBox2(docBuilder, 25, -40, 100, 20)
    Dim manPara As New Paragraph(doc)
    manPara.AppendChild(New Run(doc, "MAN"))
    man.AppendChild(manPara)
    docBuilder.InsertNode(man)

    Dim manCauseTxt As String
    manCauseTxt = "Basic qualification of the employee [Excluded as Cause]"

    Dim manCause As Shape = GetTextBox(docBuilder, -30, 5.2, 126, 190)
    Dim manCausePara As New Paragraph(doc)
    manCausePara.AppendChild(New Run(doc, manCauseTxt))
    manCause.AppendChild(manCausePara)
    docBuilder.InsertNode(manCause)
    docBuilder.StartBookmark("manCauseBookmark")
    docBuilder.Writeln()
    docBuilder.EndBookmark("manCauseBookmark")

    Dim collector As Aspose.Words.Layout.LayoutCollector = New Aspose.Words.Layout.LayoutCollector(doc)
    Dim enumerator As Aspose.Words.Layout.LayoutEnumerator = New Aspose.Words.Layout.LayoutEnumerator(doc)
    Dim bStart As BookmarkStart = doc.Range.Bookmarks("manCauseBookmark").BookmarkStart
    enumerator.Current = collector.GetEntity(bStart)
    Dim RecPositionTop As Int64 = enumerator.Rectangle.Top

    manCauseTxt = "Inattention of the sorting worker [Confirmed as Cause ]"

    Dim manCause2 As Shape = GetTextBox(docBuilder, -40, RecPositionTop, 126, 190)
    Dim manCausePara2 As New Paragraph(doc)
    manCausePara2.AppendChild(New Run(doc, manCauseTxt))
    manCause2.AppendChild(manCausePara2)
    docBuilder.InsertNode(manCause2)
    docBuilder.StartBookmark("manCause2Bookmark")
    docBuilder.Writeln()
    docBuilder.EndBookmark("manCause2Bookmark")

    Dim collector2 As Aspose.Words.Layout.LayoutCollector = New Aspose.Words.Layout.LayoutCollector(doc)
    Dim enumerator2 As Aspose.Words.Layout.LayoutEnumerator = New Aspose.Words.Layout.LayoutEnumerator(doc)
    Dim bStart2 = doc.Range.Bookmarks("manCause2Bookmark").BookmarkStart
    enumerator2.Current = collector2.GetEntity(bStart2)
    Dim RecPositionTop2 As Int64 = enumerator2.Rectangle.Top

    manCauseTxt = "Lack of experience and Training [Possible Cause]"

    Dim manCause3 As Shape = GetTextBox(docBuilder, -50, RecPositionTop2, 126, 190)
    Dim manCausePara3 As New Paragraph(doc)
    manCausePara3.AppendChild(New Run(doc, manCauseTxt))
    manCause3.AppendChild(manCausePara3)
    docBuilder.InsertNode(manCause3)

    Dim method As Shape = GetTextBox2(docBuilder, 167, -40, 100, 20)
    Dim methodPara As New Paragraph(doc)
    methodPara.AppendChild(New Run(doc, "METHOD"))
    method.AppendChild(methodPara)
    docBuilder.InsertNode(method)

    Dim machine As Shape = GetTextBox2(docBuilder, 320, -40, 100, 20)
    Dim machinePara As New Paragraph(doc)
    machinePara.AppendChild(New Run(doc, "MACHINE"))
    machine.AppendChild(machinePara)
    docBuilder.InsertNode(machine)

    Dim material As Shape = GetTextBox2(docBuilder, 15, 400, 100, 20)
    Dim materialPara As New Paragraph(doc)
    materialPara.AppendChild(New Run(doc, "MATERIAL"))
    material.AppendChild(materialPara)
    docBuilder.InsertNode(material)

    Dim measurement As Shape = GetTextBox2(docBuilder, 155, 400, 100, 20)
    Dim measurementPara As New Paragraph(doc)
    measurementPara.AppendChild(New Run(doc, "MEASUREMENT"))
    measurement.AppendChild(measurementPara)
    docBuilder.InsertNode(measurement)

    Dim environment As Shape = GetTextBox(docBuilder, 330, 400, 100, 20)
    Dim environmentPara As New Paragraph(doc)
    environmentPara.AppendChild(New Run(doc, "ENVIRONMENT"))
    environment.AppendChild(environmentPara)
    docBuilder.InsertNode(environment)


    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    Dim arrowMan As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMan.Top = 40
    arrowMan.Left = -10
    arrowMan.Width = 250
    arrowMan.Height = 3
    arrowMan.Rotation = 80
    arrowMan.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMan.StrokeColor = System.Drawing.Color.Black
    arrowMan.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMan)

    Dim arrowMethod As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMethod.Top = 40
    arrowMethod.Left = 140
    arrowMethod.Width = 250
    arrowMethod.Height = 3
    arrowMethod.Rotation = 80
    arrowMethod.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMethod.StrokeColor = System.Drawing.Color.Black
    arrowMethod.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMethod)

    Dim arrowMachine As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMachine.Top = 40
    arrowMachine.Left = 290
    arrowMachine.Width = 250
    arrowMachine.Height = 3
    arrowMachine.Rotation = 80
    arrowMachine.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMachine.StrokeColor = System.Drawing.Color.Black
    arrowMachine.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMachine)


    Dim mainArrow As Shape = New Shape(doc, ShapeType.Arrow)
    mainArrow.Top = 155
    mainArrow.Left = 0
    mainArrow.Width = 520
    mainArrow.Height = 3
    mainArrow.StrokeWeight = System.Drawing.FontStyle.Bold
    mainArrow.StrokeColor = System.Drawing.Color.Black
    mainArrow.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(mainArrow)

    Dim arrowMaterial As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMaterial.Top = 260
    arrowMaterial.Left = -10
    arrowMaterial.Width = 250
    arrowMaterial.Height = 3
    arrowMaterial.Rotation = -80
    arrowMaterial.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMaterial.StrokeColor = System.Drawing.Color.Black
    arrowMaterial.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMaterial)

    Dim arrowMeasurement As Shape = New Shape(doc, ShapeType.Arrow)
    arrowMeasurement.Top = 260
    arrowMeasurement.Left = 140
    arrowMeasurement.Width = 250
    arrowMeasurement.Height = 3
    arrowMeasurement.Rotation = -80
    arrowMeasurement.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowMeasurement.StrokeColor = System.Drawing.Color.Black
    arrowMeasurement.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowMeasurement)

    Dim arrowEnvironment As Shape = New Shape(doc, ShapeType.Arrow)
    arrowEnvironment.Top = 260
    arrowEnvironment.Left = 290
    arrowEnvironment.Width = 250
    arrowEnvironment.Height = 3
    arrowEnvironment.Rotation = -80
    arrowEnvironment.StrokeWeight = System.Drawing.FontStyle.Bold
    arrowEnvironment.StrokeColor = System.Drawing.Color.Black
    arrowEnvironment.FillColor = System.Drawing.Color.Black
    docBuilder.InsertNode(arrowEnvironment)

    docBuilder.Writeln()
    docBuilder.Writeln()
    docBuilder.Writeln()

    doc.Save("C:\\Aspose\\Files\\FRB\\outMyFileDOC.docx")

@TECHS,

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

@TECHS,

Thanks for your patience. We have modified the code example according to your requirement. Please check the attached code example. Hope this helps you. Code.zip (1.8 KB)

Thanks for your code example.
In this text string below, how can I make it bold highlight in yellow this selected text “[Excluded as Cause]” only?

“Basic qualification of the employee [Excluded as Cause]”

Dim manCauseTxt As String
manCauseTxt = “Basic qualification of the employee [Excluded as Cause]”

    Dim manCause As Shape = GetTextBox(docBuilder, 30, 100, 126, 190)
    Dim manCausePara As New Paragraph(doc)
    manCausePara.AppendChild(New Run(doc, manCauseTxt))
    manCause.AppendChild(manCausePara)
    docBuilder.InsertNode(manCause)

@TECHS,

Thanks for your inquiry. Please use Run.Font.Bold property to set the font formatting as bold and Run.Font.HighlightColor property to set the highlight color of text. Please check the following code snippet. Hope this helps you.

Dim manCauseTxt As String
manCauseTxt = "Basic qualification of the employee "

Dim manCause As Shape = GetTextBox(docBuilder, 30, 100, 126, 190)
Dim manCausePara As New Paragraph(doc)
manCausePara.AppendChild(New Run(doc, manCauseTxt))

manCauseTxt = "[Excluded as Cause]"
Dim run As New Run(doc, manCauseTxt)
run.Font.Bold = True
run.Font.HighlightColor = Color.Yellow

manCausePara.AppendChild(run)

manCause.AppendChild(manCausePara)
docBuilder.InsertNode(manCause)

Thanks for your codes.

  1. I want to write this text “[Excluded as Cause]” on a new line after highlight and bold

  2. I saved it as jpeg using ImagesaveOptions but the margins of the jpeg were too large.
    Dimension = 8500 X 11000

    How to set dimensions?

Dim opt As ImageSaveOptions = New ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg)
opt.PageIndex = 0
opt.PageCount = 1
opt.Resolution = 1000
opt.JpegQuality = 100
opt.UseHighQualityRendering = True

doc.Save(“C:\Aspose\Files\FRB\outMyFileDOC.jpeg”, opt)

  1. All these textbox positions seem to depend on others so if on section had 2 boxes instead of 3 boxes the alignment were messed upIshikawa.jpeg (1.8 MB)

@TECHS,

Please use the ControlChar.LineBreak as shown below to insert the line break.

manCauseTxt = "Basic qualification of the employee " + ControlChar.LineBreak

The ImageSaveOptions.Resolution property sets both horizontal and vertical resolution for the generated images, in dots per inch. Please reduce the resolution according to your requirement.

Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue and provide you more information. Thanks for your cooperation.

If I reduced resolution, image will look blurry.

Attached is my code

  1. I can’t seem to align all textboxes correctly. If 1 textbox is added, others will be misaligned.
  2. I want to have the output without lots of blanks at top & bottomConsoleApplication1.zip (1.4 MB)