Automatically adjusting shapes

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,


Please accept our apologies for the delay. We are working over your query and will get back to you as soon as possible.

Hi Charles,


Thanks for your patience. I managed to replicate these two problems. I have logged them in our issue tracking system as following:

DIAGRAM-33422 - The shape is not re-sized when set height/width using the shape sheet window
DIAGRAM-33423 - The connector does not snap to the center of the object

Your request has also been linked to these issues and you will be notified as soon as it is resolved and available for the public use. We’re sorry for your inconvenience.

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,


Thanks for your inquiry. Did you try with the latest version of Aspose.Diagram 3.3.0? Because when I try using the latest version of Aspose.Diagram 3.3.0, the connectors were aligned to the center. Please take a look over PDF file attached to my reply here. For now, you can adjust width and height while calling AddShape method by passing double type values. Please also highlight the problematic area with the help of snap shot etc. We will take a closer look and guide you accordingly.

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,


Well, your issues have just been reported / identified and it will take some time for our development team to further investigate the issue and provide a fix (as there are other high priority issues in the development queue). However, I have asked the responsible developer to take a look at these issues shortly. As soon as he is done with his analysis of your reported issue then we will be able to update further.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.