I’m testing Aspose.PSD and I cannot figure out how the Paragraph.Justification works.
I have the following code:
using Aspose.PSD;
using Aspose.PSD.FileFormats.Psd;
using Aspose.PSD.FileFormats.Psd.Layers;
using Aspose.PSD.ImageOptions;
var myArray = new (string text, JustificationMode jus, int yPos)[] {
($"Test left", JustificationMode.Left, 50),
($"Test center", JustificationMode.Center, 150),
($"Test right", JustificationMode.Right, 250),
};
new License().SetLicense("XXXX");
using (var psd = new PsdImage(300, 400))
{
var graphics = new Graphics(psd);
{
graphics.Clear(Color.White);
}
foreach (var myItem in myArray)
{
TextLayer textLayer = psd.AddTextLayer(myItem.text, new Rectangle(50, myItem.yPos, 200, 75));
textLayer.TextData.Items.ToList().ForEach(i =>
{
i.Style.FontSize = 12;
i.Paragraph.Justification = myItem.jus;
});
textLayer.TextData.UpdateLayerData();
}
psd.Save("mySimpleTest.psd", new PsdOptions());
}
When opening the image in Photoshop I get a dialog box
result_prompt.png (13.6 KB)
…and when I select “Update”, the centered text gets fixed, but the right-aligned is still broken
result.png (4.0 KB)
…I was expecting something like this:
Screenshot 2024-11-18 215748.png (3.8 KB)
…What am I missing?
How do I properly align the portions in a text layer?
Also, is there a way to prevent the dialog box from appearing in the first place?
Thanks.
ps: I’m using both “Aspose.PSD” & “Aspose.Drawing” (from Nuget) version 24.11.0.
ps2: I’m also using Adobe Photoshop 26.0.0 Release