Multiline text field gains top margin when flattened

The below code sets the value of a multiline text field with five lines and then flattens and saves a new pdf. Viewing the pdf in Edge or Chrome shows that there is a margin before the first line of text and the last line is partially visible.

Opening the template pdf in Edge and entering five lines works correctly. The last line is not cut off.
I am using Aspose.PDF for .NET 23.4

template.pdf (6.4 KB)
out.pdf (5.0 KB)

image.png (2.7 KB)

using Aspose.Pdf.Forms; 
new Aspose.Pdf.License().SetLicense("Aspose.PDF.NET.lic"); 

var pdf = new Aspose.Pdf.Document(@"C:\Source\Test\Aspose\MultiLineHeightBug\template.pdf"); 
var textBoxField = pdf.Form["Text1"] as TextBoxField; 
textBoxField.Value = "line 1\r\nline 2\r\nline 3\r\nline 4\r\nline 5"; 
pdf.Flatten(); 
pdf.Save(@"C:\Source\Test\Aspose\MultiLineHeightBug\out.pdf");

@vcciictaccounts,

I tried different ways to fix the issue. Modifying the borders and the vertical alignment, but nothing fixed the problem, so this seems to be a bug. I will create a ticket for the dev team.

@vcciictaccounts
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-54483

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.