I am trying to build a chart with Aspose.Diagrams and then save it as a PDF and I have noticed that Aspose doesn’t automatically adjust dynamic shape properties.
For example, even though I have shape.XForm.LocPinX.Ufe.F = “Width*0.5”, the connector that I attach doesn’t snap to the center of the object, instead it is off-centered.
Also, when I set the height of a shape with ‘shape.XForm.Height.Ufe.F = “=TEXTHEIGHT(TheText,TxtWidth)”’, the shape isn’t re-sized.
How do I get Aspose to apply these shape settings so that the file renders correctly?
I have attached sample code that shows the issues I am having.
Hi Charles,
Hi Charles,
Hi Charles,
the connector that i attach doesn’t snap to the center of the object, instead it is off-centered.
It is to update you that, as a workaround, you can try using the following source code:
Dim visioStencil As String = “Stencil2.vss”
'Names of the masters present in the stencil
Dim rectangleMaster As String = "Rectangle", connectorMaster As String = "Dynamic connector"
Dim posX As Double = 5
Dim posY As Double = 7.5
Dim width As Double = 0.75
' Create a new diagram
Dim diagram As Diagram = New Diagram(visioStencil)
diagram.Pages(0).PageSheet.PageProps.PageHeight.Value = 8
diagram.Pages(0).PageSheet.PageProps.PageWidth.Value = 11
Dim rectangleId As Long = diagram.AddShape(posX, posY, 2.0, 0.59055118110236227, rectangleMaster, 0)
Dim header As Shape = diagram.Pages(0).Shapes.GetShape(rectangleId)
header.Line.LineWeight.Value = 0.01
header.Text.Value.Add(New Txt("header"))
header.SetWidth(2)
posX = 0.5
Dim spacing As Double = 0.1
For i As Integer = 0 To 10
posY = 6.5
Dim rectangleId2 As Long = diagram.AddShape(posX, posY, 0.75, 0.59055118110236227, rectangleMaster, 0)
Dim topic As Shape = diagram.Pages(0).Shapes.GetShape(rectangleId2)
topic.Line.LineWeight.Value = 0.01
topic.Text.Value.Add(New Txt("topic"))
Dim topicConnector As New Shape
Dim connectorId As Long = diagram.AddShape(topicConnector, connectorMaster, 0)
topicConnector.Line.EndArrow.Value = 0
topicConnector.Align.AlignTop.Value = 0
diagram.Pages(0).ConnectShapesViaConnector(header.ID, ConnectionPointPlace.Bottom, topic.ID, ConnectionPointPlace.Top, connectorId)
posY -= topic.XForm.Height.Value + 0.2
Dim previousSectionId As Long = Nothing
For j As Integer = 0 To 5
Dim rectangleId3 As Long = diagram.AddShape(posX, posY, 0.75, 0.59055118110236227, rectangleMaster, 0)
Dim section As Shape = diagram.Pages(0).Shapes.GetShape(rectangleId3)
section.Line.LineWeight.Value = 0.01
section.Text.Value.Add(New Txt("section"))
section.Line.LineWeight.Value = 0.02
Dim sectionConnector As New Shape
Dim sectionConnectorId As Long = diagram.AddShape(sectionConnector, connectorMaster, 0)
sectionConnector.Line.EndArrow.Value = 0
If previousSectionId = Nothing Then
diagram.Pages(0).ConnectShapesViaConnector(topic.ID, ConnectionPointPlace.Bottom, section.ID, ConnectionPointPlace.Top, sectionConnectorId)
Else
diagram.Pages(0).ConnectShapesViaConnector(previousSectionId, ConnectionPointPlace.Bottom, section.ID, ConnectionPointPlace.Top, sectionConnectorId)
End If
previousSectionId = section.ID
posY -= section.XForm.Height.Value + 0.2
Next
posX += width + spacing
Next
diagram.Save("Output.pdf", SaveFileFormat.PDF)
diagram.Save(“Output.vdx”,
SaveFileFormat.VDX)
Please let me know in case of any confusion or questions.
I just tried the code work arround and it didn’t make any difference. The connectors are not aligned and the heights aren’t adjusting.
Hi Charles,
Oh, I see what I was doing wrong.
I have the connectors aligning now.
Is there any estimate on when the issue will be fixed so I can use dynamically sized rectangles?
Hi Charles,
The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.