Hello,
I am trying to add some text to the an existing PDF document using a text stamp and am not seeing the behavior as I would expect.
I add a text stamp with a particular height and width but if I put a large amount of text into the stamp it doesn’t respect the height of text stamp. The height of the stamp is increase and the text overflows into the rest of the document.
I would expect that the size of the text stamp would not change the the content would be clipped. Below is an example of the code I am using to create a text stamp with a width and height of 100x50.
Is this just not something that is possible?
Thanks
Here is the code:
static void Test()
{
var pdf = new Document();
var page = pdf.Pages.Add();
var stamp = new TextStamp("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
stamp.Width = 100;
stamp.Height = 50; // doesn't resect the height
stamp.LeftMargin = 10;
stamp.RightMargin = 5;
stamp.TopMargin = 5;
stamp.WordWrap = true;
stamp.TextState.FontSize = 11;
stamp.Background = true;
stamp.Scale = false;
stamp.TextAlignment = HorizontalAlignment.Left;
stamp.TextState.HorizontalAlignment = HorizontalAlignment.Left;
stamp.VerticalAlignment = VerticalAlignment.Top;
stamp.HorizontalAlignment = HorizontalAlignment.Left;
stamp.TextState.BackgroundColor = Color.LightBlue;
page.AddStamp(stamp);
pdf.Save(@"d:\output\textstamp.pdf");
}