Hi! Need your .net library to change text on particular layer in PSD file. Just to keep text style parameters remained the same (color, size etc), as well as text location on image. Is that possible?
Also is there a demo? Or can I buy license for 1 month for testing and how much does it cost?
public static void ReplaceTextInLayer(string psdFilePath, string outputJpegFilePath, string layerName, string newText)
{
// Instantiate the License class
Aspose.PSD.License license = new Aspose.PSD.License();
// Pass the name of the embedded license file
license.SetLicense("Aspose.PSD.NET.lic");
// Load an existing PSD file
using (PsdImage psdImage = (PsdImage)Image.Load(psdFilePath))
{
foreach (var layer in psdImage.Layers)
{
// Check if layer is a text layer and has the specified name
if (layer is TextLayer && layer.Name == layerName)
{
TextLayer textLayer = (TextLayer)layer;
// Replace the text in the text layer
textLayer.UpdateText(newText);
break; // Remove the break if you expect multiple layers with the same name and want to update all
}
}
// Create an instance of JpegOptions and set its various properties
Aspose.PSD.ImageOptions.JpegOptions options = new Aspose.PSD.ImageOptions.JpegOptions();
// You can set the quality of the output JPEG here, 100 being the highest
options.Quality = 100;
// Save the flattened image as a JPEG file
psdImage.Save(outputJpegFilePath, options);
}
}
However strange thing happens. See my pdf: image.jpg (62,7 KB)
after executing this method to edit “read more” text, after saving to jpeg I see it moved somehow the text on text layer above. Why could that happen?
I can move this topic to the “Sales” category. Sales team can help with the best choice. Also, if you only need minimum Aspose.PSD Functionality you can check Aspose.PSD Plugins Process PSD, PSB, AI files with API. Graphics Editor can be suitable for your case PSD Graphics Editor via .NET
@lofti please check if the font from your file is installed. Also, There are can be minor differences in position of Text because of Aspose.PSD Text Engine differences. And there are additional special cases. Text in PSD Layer can be aligned by left, center, top etc. If you change text, Aspose.PSD will try to save the position of Left-Top Corner of Text Layer