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

Free Support Forum - aspose.com

Psd TextLayer not working

I’ve a Psd and it has 2 layers.

  1. image_background
  2. image_text

I just download the demo and run the code but not able to load TextLayer as it’s coming null and throwing “Objcet reference not set…” error.

I’m using this code:

// Load a PSD file as an image and caste it into PsdImage
        string filePath = RunExamples.GetDataDir_PSD() + "testPsdFile.psd";
        using (PsdImage image = (PsdImage)Image.Load(filePath))
        {
            foreach (var layer in image.Layers){
                PsdImage psdImage = image;
                if (layer.Name == "image_background")
                {

                }
                else if (layer.Name == "image_text")
                {
                    TextLayer layer_text = psdImage.Layers[1] as TextLayer as TextLayer;
                    Debug.Assert(layer_text != null, "layer_text != null");
                    layer_text.UpdateText("test update", new Point(100, 100), 72.0f, Color.Purple);
                }
            }               
        }

Am I missing something or it’s a know issue?

@modi.pooja.m,

I have observed the issue shared by you and request you to please share the source PSD file to further investigate the issue on our end.