I have the problem that when I open the psd file in photoshop it tells me that “some textlayers need to be updated” . What I am doing is taking the measurements of another layer “#lsak_007#cl” and
having that layer as a reference, is to add a centered text layer
Code:
string sourceFile = "C:\\TestPSDPrueba2.psd";
string outputFile = "C:\\3_Output_Test_PSD_2daPruebas_Punto_3.psd";
var left = 0;
var right = 0;
var top = 0;
var bottom = 0;
var witdh = 0;
var height = 0;
Size size = new Size();
PsdImage img = (PsdImage)Image.Load(sourceFile);
foreach (var layer in img.Layers)
{
if (layer.DisplayName == "#lsak_007#cl")
{
size = layer.Size;
left = layer.Left;
right = layer.Right;
top = layer.Top;
bottom = layer.Bottom;
witdh = layer.Width;
height = layer.Height;
}
}
var medio = (height / 2);
// var resta = medio - (medio / 2);
Point location = new Point(left, top);
// Add a text layer
TextLayer textLayer = img.AddTextLayer("test", new Rectangle(left, right, size.Width, size.Height));
IText textData = textLayer.TextData;
ITextStyle defaultStyle = textData.ProducePortion().Style;
ITextParagraph defaultParagraph = textData.ProducePortion().Paragraph;
// defaultStyle.FillColor = Color.DimGray;
// defaultStyle.FontSize = 51;
// set text
ITextPortion[] newPortions = textData.ProducePortions(new string[]
{
"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui dicta minus molestiae vel beatae natus eveniet ratione temporibus.","Aalias officiis assumenda officia quibusdam delenit. Beatae natus eveniet ratione temporibus aperiam harum alias officiis assumenda officia quibusdam delenit beatae natus eveniet ratione temporibus aperiam harum alias officiis assumenda officia quibusdam delenit officia quibusdam delenit officia quibusdam delenit officia quibusdam delenit"
},
defaultStyle,
defaultParagraph);
newPortions[0].Style.FauxBold = true;
newPortions[0].Style.FillColor = Color.Red;
newPortions[0].Style.FontName = FontSettings.GetAdobeFontName("Segoe UI Semibold");
newPortions[1].Style.FillColor = Color.Blue;
newPortions[1].Style.FontName = FontSettings.GetAdobeFontName("Segoe UI Semibold");
// //add portion
// textLayer.TextData.RemovePortion(0);
textLayer.TextData.AddPortion(newPortions[0]);
textLayer.TextData.UpdateLayerData();
textLayer.TextData.AddPortion(newPortions[1]);
textLayer.TextData.UpdateLayerData();
img.Save(outputFile);