We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text has wrong alignment when saved in .VSDX or .EMF

In the diagram generated by the following code, when saved in .VSDX or .EMF, the text in "Start 7", and "Circle" shapes is not centered. Can you help to check and fix ?

// http://www.aspose.com/docs/display/diagramnet/Create+a+New+Diagram

// https://github.com/aspose-diagram/Aspose.Diagram-for-.NET/tree/master/Examples/Data/Knowledge-Base

// https://forum.aspose.com/t/4882

public static void Test1()

{

// Create a new diagram, Basic Shapes.vss is from aspose github

Diagram diagram = new Diagram(@"Basic Shapes.vss", LoadFileFormat.VSS);

// Add a new rectangle shape

long shapeId = diagram.AddShape(4.25, 5.5, 2, 1, @"Rectangle", 0);

Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(@"Rectangle text."));

// Add a new star shape

shapeId = diagram.AddShape(2.0, 5.5, 2, 2, @"Star 7", 0);

shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(@"Star text."));

// Add a new hexagon shape

shapeId = diagram.AddShape(7.0, 5.5, 2, 2, @"Hexagon", 0);

shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(@"Hexagon text."));

// Add a new circle shape

shapeId = diagram.AddShape(2.0, 2.5, 2, 2, @"Circle", 0);

shape = diagram.Pages[0].Shapes.GetShape(shapeId);

shape.Text.Value.Add(new Txt(@"Circle 1."));

// Add a new circle shape

shapeId = diagram.AddShape(2.0, 8.0, 2, 2, @"Circle", 0);

shape = diagram.Pages[0].Shapes.GetShape(shapeId);

Para para = new Para();

para.IX = shape.Paras.Add(para);

para.HorzAlign.Value = HorzAlignValue.Center;

shape.Text.Value.Add(new Txt(@"Circle 2."));

// Save the new diagram

// Bug: In .vsdx and .emf, the text in "Start 7", and "Circle" shapes is not centered.

string outputDiagramPath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;

diagram.Save(outputDiagramPath + ".vsdx", SaveFileFormat.VSDX);

diagram.Save(outputDiagramPath + ".vdx", SaveFileFormat.VDX);

diagram.Save(outputDiagramPath + ".emf", SaveFileFormat.EMF);

}

Hi Jiaguo,


Thank you for contacting support. Please set the text position of each shape in the code as below:

[.NET, C#]
shape.Text.Value.Add(new Txt(@“Circle 1.”));
// set text position
shape.TextXForm.TxtPinX.Ufe.F = “Width0.5";
shape.TextXForm.TxtPinY.Ufe.F = "Height
0.5”;

Please let us know in case of any confusion or questions.


The situation is better but still wrong. More specifically, with your code, the text is centered when saved in .VSDX, but still not centered when saved in .EMF. Can you help to check and fix ?

Hi Jiaguo,


Thank you for the details. We managed to replicate the problem of text alignment in circles and star shapes when saving in the EMF format. It has been logged under ticket ID DIAGRAMNET-51080 in our bug tracking system. Your post has also been linked to this ticket. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

The issues you have found earlier (filed as DIAGRAMNET-51080) have been fixed in Aspose.Diagram for .NET 17.02.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.