This is somewhat related to Paragraph.Justification not working as expected - Free Support Forum - aspose.com
Hi,
It seems Paragraph.Justification is broken.
When creating a PSD from scratch, I’m unable to horizontally align my text and all text move both horizontally and vertically (1px) when edited in Photoshop.
When opening the file it looks like this:
justOpened.png (4.6 KB)
…after editing them (not making any actual change, just click it with the text tool):
afterUpdate.png (1.8 KB)
(both images have lines to help visualice the issue, that are not in the code sample, if you need the code WITH the lines code included, I can provide).
Please advice.
Framework: net8.0
Aspose.Drawing: 25.2.0
Aspose.PSD: 25.1.0
using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
new License().SetLicense("XXXX");
var CreateText = (PsdImage psd, string text, int y, Color fontColor, JustificationMode hAlign) =>
{
var textLayer = psd.AddTextLayer(text, new Rectangle(75, y, 225, 75));
textLayer.TextData.Items.ToList().ForEach(i =>
{
i.Style.FontName = FontSettings.GetAdobeFontName("Arial");
i.Style.FontSize = 48;
i.Style.FillColor = fontColor;
i.Paragraph.Justification = hAlign;
});
textLayer.TextData.UpdateLayerData();
};
using (var psd = new PsdImage(400, 400))
{
var graphics = new Graphics(psd);
{
graphics.Clear(Color.White);
}
// LEFT ALIGNMENT TEST (red)
CreateText(psd, "I(left)", 50, Color.Red, JustificationMode.Left);
// CENTER ALIGNMENT TEST (green)
CreateText(psd, "I(center)", 150, Color.Green, JustificationMode.Center);
// RIGHT ALIGNMENT TEST (blue)
CreateText(psd, "I(right)", 250, Color.Blue, JustificationMode.Right);
psd.Save("myRevisitedTest.psd");
}