When text is updated with / characters, file cannot be opened in Photoshop

@rlaskowski.sdl,

I have observed your comments and like to share that using following sample code, we have obtained the attached output result. Can you please verify on your end.

            string filePath = "example.psd";
            using (var image = Image.Load(filePath))
            {
                if (!(image is PsdImage)) return;

                var psdImage = (PsdImage)image;
                var layers = psdImage.Layers;

                for (var index = layers.Length - 1; index >= 0; index--)
                {
                    var layer = layers[index];

                    if (!(layer is TextLayer)) continue;

                    var textLayer = (TextLayer)layer;

                    // to update text use the method UpdateText
                    textLayer.UpdateText("/");
                    // or
                    // you can use also iText functional
                    //textLayer.TextData.RemovePortion(0);
                    //ITextPortion portion = textLayer.TextData.ProducePortion();
                    //portion.Text = "/";
                    //textLayer.TextData.AddPortion(portion);
                    //textLayer.TextData.UpdateLayerData();
                }

                var imageOptions = new PsdOptions(psdImage);

                var fileName = Path.GetFileName(filePath);
                var outputFilePath = Path.GetDirectoryName(filePath) + "\\target_" + fileName;
                psdImage.Save(outputFilePath, imageOptions);
            }

psdnet203_1.zip (30.0 KB)

Hi,
I tested the file in your attachment and works perfectly.
But when I tried to use your code on my machine, I get the file which doesn’t work. I adapted the code to uniquely identify namespaces as there is bit of mess between PSD and Imagining namespaces:
string filePath = “example.psd”;
var asposeLicenser = new AsposeLicenser();
asposeLicenser.LoadLicense();
using (var image = Aspose.PSD.Image.Load(filePath))
{
if (!(image is Aspose.PSD.FileFormats.Psd.PsdImage)) return;

            var psdImage = (Aspose.PSD.FileFormats.Psd.PsdImage)image;
            var layers = psdImage.Layers;

            for (var index = layers.Length - 1; index >= 0; index--)
            {
                var layer = layers[index];

                if (!(layer is Aspose.PSD.FileFormats.Psd.Layers.TextLayer)) continue;

                var textLayer = (Aspose.PSD.FileFormats.Psd.Layers.TextLayer)layer;

                // to update text use the method UpdateText
                textLayer.UpdateText("/");
                // or
                // you can use also iText functional
                //textLayer.TextData.RemovePortion(0);
                //ITextPortion portion = textLayer.TextData.ProducePortion();
                //portion.Text = "/";
                //textLayer.TextData.AddPortion(portion);
                //textLayer.TextData.UpdateLayerData();
            }

            var imageOptions = new Aspose.PSD.ImageOptions.PsdOptions(psdImage);

            var fileName = Path.GetFileName(filePath);
            var outputFilePath = Path.GetDirectoryName(filePath) + "\\target_" + fileName;
            psdImage.Save(outputFilePath, imageOptions);

Note, we tested this on multiple machines, Win10 EN, Visual Studio 2019

@rlaskowski.sdl,

I have worked with code and source file and unable to observe issue. I have tested this issue on Windows 10 with visual studio 2019. I have also shared my generated result with you for your kind reference.ex1.zip (12.1 KB)

Hi,
can you please share with us the whole project with the dependencies? We will try to compare with what we have to see what can be different.

@rlaskowski.sdl,

I like to inform that i have used 19.9 and sample code shared by you and successfully generated result.

Hi,
please see attached solution with all the dependencies, when I use this, on multiple machines I’m getting error with the file you send me earlier - basically generated file cannot be opened in Photoshop.
PSDIssueStarter.zip (2.6 MB)

Can you test it and see what you get? Could it be some Windows dependency missing?

@rlaskowski.sdl,

Can you please try using suggested sample code on your end using Aspose.PSD for .NET 19.9 and share your feedback with us.

            string filePath = "example.psd";
            using (var image = Image.Load(filePath))
            {
                if (!(image is PsdImage)) return;

                var psdImage = (PsdImage)image;
                var layers = psdImage.Layers;

                for (var index = layers.Length - 1; index >= 0; index--)
                {
                    var layer = layers[index];

                    if (!(layer is TextLayer)) continue;

                    var textLayer = (TextLayer)layer;

                    // to update text use the method UpdateText
                    textLayer.UpdateText("/");
                    // or
                    // you can use also iText functional
                    //textLayer.TextData.RemovePortion(0);
                    //ITextPortion portion = textLayer.TextData.ProducePortion();
                    //portion.Text = "/";
                    //textLayer.TextData.AddPortion(portion);
                    //textLayer.TextData.UpdateLayerData();
                }

                var imageOptions = new PsdOptions(psdImage);

                var fileName = Path.GetFileName(filePath);
                var outputFilePath = Path.GetDirectoryName(filePath) + "\\target_" + fileName;
                psdImage.Save(outputFilePath, imageOptions);
            }

psdnet203_1.zip (30.0 KB)

This is exactly same code I sent you in attached project - simply doesn’t work. Can you compile it on your machine and send me the resulting libraries - so I can test if it will work on my machine?

@rlaskowski.sdl,

I have shared complete working sample project with you, from which i have successfully generated source file.ConsoleApp235.zip (2.7 MB)

could you please change it so it expects license next to the executable? So I can use it on my machine.
Thanks

@rlaskowski.sdl,

I have not been able to understand your requirements. Can you please elaborate.

when I run the tool it returns error:
Failed to set license. Details: Cannot find license ‘F:\Aspose Work\Aspose.Total.NET.lic’.
I expect that the license is not embedded so I’m asking if the app can be changed to load it from the same folder?

@rlaskowski.sdl,

I have observed the details shared by you. It seems that API is not able to locate the license file. I suggest you to please visit this documentation link for possible options to load license in application.

sorry, the application was send by you, has nothing to do with me and reading the documentation

@rlaskowski.sdl,

Please accept my apologies for inconvenience on your end. We added the ticket with ID PSDNET-203 based on your following query:

In my last post, we share the sample code as well as suggest you to try using latest Aspose.PSD 19.9 on your end for rectification of above mentioned issue.

If there is any thing else, please feel free to share with us and we will try our best to assist you further.

HI,
I have a problem to understand your answer.
You said you fixed the issue - but I can consistently reproduce it on multiple machines when I build the code you provided.
In order to make sure that it’s environment related (even we tested 3 different machines with no luck) I asked if you can send me compiled application which I can run on these problematic machines and see if that will help . Application you sent me doesn’t work and it fails with error missing license - from the error, the app is looking for license on specific drive which doesn’t exist on my machine. I suggested to update the app so I can supply path to our license - but it seems you failed to understand what I’m trying to tell.
What you suggest is next step - as for sure this issue is not fixed.

@rlaskowski.sdl,

We are greatly sorry for inconvenience on your end. Can you please share the output that you have achieved using latest suggested code on your end and I will update the issue status with your result in our issue tracking system for further analysis.

This issue seems to be fixed in in 19.10

@rlaskowski.sdl,

Thank you for sharing the feedback.