DomPDF display data table except last page
the way you are loading in pdf is as a string and is not rendering html code. For rendering as html code you must put it inside loadHtml()
$pageText must be inside loadHtml().
You should keep the html codes inside loadHtml().
Or you can make a separate file using html for making pdf. you can check out documentation