Line number control

I have a Multiple Lines Text box and a 1000 character limit is set.
This works OK as long as the user writes only the text.

Then the user starts to use ENTER when writing, to move to a new line.
In this case, it completely destroys the printout into a pdf document, where I have a specific text box.

Is there any trick I can set for the line limit?
For example, 10 lines limit?

I have already found a solution on the web

I inserted the following code into onValidate and now have control over the number of lines and the number of characters.

$string = {service_description};

$lines = array_slice(explode("
", $string), 0, 10); // max 10 lines

foreach ($lines as $key => $value)
{
$lines[$key] = substr(trim($value), 0, 132); // max 132 chars in line
}

$string = implode("
", $lines);

{service_description} = $string;