Single form with master / detail records - export to pdf page break

I have a single form with two master detail editable grids attached. Is there any way when exporting to pdf to be able to set an automatic page break after the master form? I have tried just setting the field sizes to be large enough for it to print on one page but it seems that it keeps changing the size of the master form dynamically depending on how much information is being printed by the detail grids. It’s weird. Any thoughts?

Also, I set the pdf to print Letter but it keeps defaulting to A4 no matter what I do. Anyone else have this issue?

it is necessary at this moment to define a number of lines and to attribute it to a variable $x, to calculate the height in pixel of a line and to attribute it to a value $y, according to the number of lines it is then possible to define the size of the pixel of a character in general, and when a line count greater than the one defined defines the value of the page break
$pdf-> addpage();