Hello.
I use latest Aspose.PSD version. I have a psd file which contains a smart object. The smart object has TextLayer. When I try to change a text value and replace the layer, the text has an incorrect style. It is longer and bigger. Any solution how to fix it? Thanks.
PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
psdLoadOptions.LoadEffectsResource = true;
string inputFile = "c:\\psd\\test\\source.psd";
using (PsdImage psdImage = (PsdImage)Image.Load(inputFile, psdLoadOptions))
{
psdImage.Save("c:\\psd\\test\\source.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
SmartObjectLayer smartObject = FindLayer("smart-object", psdImage) as SmartObjectLayer;
using (PsdImage smartObjectImage = (PsdImage)smartObject.LoadContents(psdLoadOptions))
{
Layer layer = FindLayer("text", smartObjectImage);
if (layer is TextLayer textLayer) {
// textLayer.UpdateText("changed text"); // with changed text or without no difference
}
smartObject.ReplaceContents(smartObjectImage);
}
psdImage.Save("c:\\psd\\test\\target.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
public Layer FindLayer(string layerName, PsdImage image)
{
// Get aa layers in PSD file
var layers = image.Layers;
// Find desired layer
foreach (var layer in layers)
{
// Match layer's name
if (string.Equals(layer.DisplayName, layerName, StringComparison.InvariantCultureIgnoreCase))
{
return layer;
}
}
return null;
}
test.zip (4.2 МБ)