Aspose.PSD text layer issue

Hello.
We have a simple app (testing purposes) that iterates through all the text layers of a PSD file, creates a new text Portion with empty text, adds it to the layer, and saves it.
The end result seems to be wrong, or something happens in the processing itself, as we get some shifted layers and/or shifted text inside them.

Code:
var psdImage = (PsdImage)Image.Load(psdFilePath);
var imageOptions = new PsdOptions(psdImage);
var psdSaveName = $“{psdSavePath}.psd”;
psdImage.Save(psdSaveName, imageOptions);
psdImage.Dispose();

Starting from the document:
LIssue2.zip (122.8 KB)

We get the following document:
LIssue2_result.zip (108.4 KB)

A picture of the differences (using WinMerge app for comparison):
image.png (84.9 KB)

In the resulted document, the second text layer seems to be moved to the left and cut, but here’s the kicker: If you open the resulting document in Photoshop and click on that particular shifted text, it will be repaired back to expected position.

Not sure why this is happening, but it seems to me like it only happens with longer texts and has something to do with the layer size or the container size?
I first reproduced this after iterating through layers and adding portions to each one, but it manages to reproduce just by opening and saving the doc.

Any idea of what is happening?
Version used [Aspose.PSD 24.9.0]
Let me know if you need further information

@IBurzoEvoRWS
Could you please additionally provide the code with the adding of text portions to complete task description.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PSDNET-2204

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Original code was:

var psdImage = (PsdImage)Image.Load(psdFilePath);
foreach (var layer in psdImage.Layers)
{
if (layer is TextLayer textLayer)
{
var newPortion = textLayer.TextData.ProducePortions(
new[] { “” },
null,
null
).First();

    textLayer.TextData.AddPortion(newPortion);
    textLayer.TextData.UpdateLayerData();
}

}
var imageOptions = new PsdOptions(psdImage);
var psdSaveName = $“{psdSavePath}”;
psdImage.Save(psdSaveName, imageOptions);
psdImage.Dispose();

But I realized you don’t actually have to manipulate the layers in order to reproduce this issue,
so i went with the shorter version, but here you go :slight_smile:

Thank you. I’ve updated issue with full code. I’ll write you back if we will able to find issue fast, otherwise, it will be delivered according to our support policy.