XFA Form PDF Flattening to resize the overflowing content in Text Areas

I have a PDF Form (XFA). it contains text areas as well. when i enter the data into those text areas overflowing text, and flatten it, the data at the end does not display. it displays as plus(+) icon, and the following text is hidden. is there a way to auto resize those text areas so that all the text is seen when flattened?

@g14all

Can you please share your sample PDF along with the code snippet with us? We will test the scenario in our environment and address it accordingly.

Sample MedWatch.pdf (199.4 KB)

I have atatched the sample PDF. Third page in the PDF has such data. First text area, i have filled with such large overflowing data.

I have tried multiple code snippets below is one such.

Document srcDoc = new Document(path);
       srcDoc.getForm().setType(FormType.Standard);
       srcDoc.getForm().flatten();
       srcDoc.save(targetPath);

please let me know.

@g14all

We received different output where only two pages were in the generated PDF.
output.pdf (748.7 KB)

Can you please share the output generated at your end using 24.6 version of the API?