Text all in one place and weirdly formatted after replacing shape text

Hi everyone

We’re trying to replace shape text to translate the shapes, so we’re creating a copy of the original vsdx file with updated shape texts.

The code looks as follows:
var fileBytes = await _httpClient.GetByteArrayAsync($"{_basePath}/_api/web/getfilebyserverrelativeurl(’{serverRelativePath}’)/$value");
using var stream = new MemoryStream(fileBytes);
var diagram = new Diagram(stream);

foreach (Shape shape in GetProcessableShapes(diagram.Pages[0].Shapes))
{
var activity = activities.SingleOrDefault(x => x.ActivityID == shape.Name); // These items contain the translated text
if (activity == null)
{
continue;
}
else
{
shape.Text.Value.Clear();
shape.Text.Value.Add(new Txt(activity.LangTitle));
}
}
using var stream = new MemoryStream();
diagram.Save(stream, GetSaveFormat(diagramItem.Filename)); // returns vsdx

This Updating the text leads to weird formatting (that is also different every time we run the code). All text is in one place, uses a big font, a different text color or a combination of all of them. Please see the files attached (“translated_Control of faulty products in QM (Be) horizontal.vsdx” contains the errors, the other one is the original):
Translation Weird formatting.7z (202.8 KB)

Screenshot of the issue: 2022-11-29_09-06-05.png (16.9 KB)

Can you help us?

We’re using Aspose.Diagram 22.11.0

@IOZ
Please also clear the chars of shape:
shape.Chars.Clear();
shape.Text.Value.Clear();
Thanks.

That worked perfectly! Thank you for the quick response!