Add TextLayer Error

After loading the psd file, add an existing layer, image.AddTextLayer(image.Layers[0]); and then edit the content of image.Layers[1].layer, it will prompt that it exceeds the index range.

Then edit the original text layer. After editing, the content of the added layer will also change.

@zhengyannan

Please share the working sample code along with source file and snapshot of issue incurring. I will try my best to help you further based on shared information.

<a class=“attachment” href="/uploads/discourse_instan image.png (69.5 KB)ce3/53252">image.png (6.1 KB)

Uploading: 1626933335.jpg…

1626933335.png (83.2 KB)

title.zip (5.4 MB)

@zhengyannan

Can you please share which PsdLoadOptions you have used along with product version as I am getting exception even on loading PSD.
image.png (128.0 KB)

using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Psd.Layers;
using Aspose.PSD.ImageLoadOptions;
using System;
using System.Collections.Generic;
using System.Text;

namespace Insight.Aspose.Multi_Language
{
class Test
{
static void Main(string[] args)
{
Console.WriteLine(“Start”);
var path = @“E:\Aspose\3InputFiles”;
var fileName = @“title.psd”;
var outFileName = @“title_text”;
var outFileNameTwo = @“title_text_two”;

        var license = new License();
        license.SetLicense("Aspose.PSD.NET.lic");

        var psdLoadOptions = new PsdLoadOptions();
        //psdLoadOptions.BufferSizeHint = 102400;
        //psdLoadOptions.UseDiskForLoadEffectsResource = true;

        using (PsdImage image = (PsdImage)Image.Load(path + fileName, psdLoadOptions))
        {
            var len = image.Layers.Length - 1;
            for (var i = 0; i < 2; i++)
            {
                var group = image.AddLayerGroup("NO_" + i, image.Layers.Length, true);
                for (var j = 1; j < len; j++)
                {
                    group.AddLayer(image.Layers[j]);
                }
            }
            image.Save(path + outFileName);
            image.Dispose();
        }

        using (PsdImage image2 = (PsdImage)Image.Load(path + outFileName, psdLoadOptions))
        {
            var length = image2.Layers.Length;
            for (var i = 0; i < length; i++)
            {
                if (image2.Layers[i] is TextLayer)
                {
                    var textlayer = image2.Layers[i] as TextLayer;

                    textlayer.UpdateText("text");
                }
            }
            image2.Save(path + outFileNameTwo);
            image2.Dispose();
        }
    }
}

}

The Aspose version used is 21.7.

The exception is that after loading the PSD and using the addTextLayer method, the created layer cannot really modify the text layer on the index.

@zhengyannan

I have added at ticket with ID PSDNET-942 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.