Is it possible to place text inside a rectangle?

Is it possible to place text inside a rectangle?

Forum member · May 12, 2020
MergeDocument doc = new MergeDocument("D:\\TestData\\OMTI_NDB Assure_SOC2_EngLtr__01 17 2020 vf.pdf"); Rectangle rectangle = new Rectangle(100, 100, 50, 50); rectangle.BorderStyle = LineStyle.Solid; rectangle.CornerRadius = 5; rectangle.FillColor = RgbColor.Yellow; rectangle.ID = "Exhibit 1 Rectangle"; TextArea textArea = new TextArea("Exhibits 1", 105, 105, 40, 40); textArea.ID = "Exhibit 1 Text"; doc.Pages[0].Elements.Add(rectangle); doc.Pages[0].Elements.Add(textArea); This works, but it is difficult to align the text. Is there a better way?

Re: Is it possible to place text inside a rectangle?

Support · May 12, 2020
Hello, You can achieve this by setting the rectangles x, y width and height based on the same values used for the TextArea then using the align and vAlign properties of the TextArea. Here is a code sample: MergeDocument doc = new MergeDocument(@"Input PDF file path"); Rectangle rectangle = new Rectangle(105, 105, 60, 50); rectangle.BorderStyle = LineStyle.Solid; rectangle.CornerRadius = 5; rectangle.FillColor = RgbColor.Yellow; rectangle.ID = "Exhibit 1 Rectangle"; TextArea textArea = new TextArea("Exhibits 1", 105, 105, 60, 50); textArea.ID = "Exhibit 1 Text"; textArea.Align = TextAlign.Center; textArea.VAlign = VAlign.Center; doc.Pages[0].Elements.Add(rectangle); doc.Pages[0].Elements.Add(textArea); doc.Draw(@"Output PDF file path"); Thanks, ceTe Software Support Team