The error occurs when adding 2 portions, a title with a line break and the rest of the text. When this happens in Photoshop, when updating the textlayers, the line break is lost
beforeUpdate.jpg (113.2 KB)
afterUpdate.jpg (105.5 KB)
PSDTest3.zip (441.1 KB)
Code:
string sourceFile = Directory.GetCurrentDirectory() + "/files-input/PSDTest3.psd";
string outputFile = Directory.GetCurrentDirectory() + "/files-output/Test_Output";
PsdImage image = (PsdImage)Aspose.PSD.Image.Load(sourceFile);
var layer2 = image.AddTextLayer("New layer", new Aspose.PSD.Rectangle(117, 150, 350, 200));
var textDataTL = layer2.TextData;
ITextStyle defaultStyleTL = textDataTL.ProducePortion().Style;
ITextParagraph defaultParagraphTL = textDataTL.ProducePortion().Paragraph;
ITextPortion[] newPortionsTL = textDataTL.ProducePortions(
new string[] { "Tile\r", "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui dicta minus molestiae vel beatae natus" },
defaultStyleTL,
defaultParagraphTL);
// Updating of default styles
newPortionsTL[0].Style.FontSize = 14;
newPortionsTL[1].Style.Leading = 20;
newPortionsTL[1].Style.FontSize = 10;
// Removing old text
textDataTL.RemovePortion(0);
// Addint new text portions
foreach (var newPortion in newPortionsTL)
{
textDataTL.AddPortion(newPortion);
}
// Applying text update
textDataTL.UpdateLayerData();
image.Save(outputFile);