How to detect blocks of texts in document images
I would approach the text block amalgamation as a clustering problem. If you define a suitable distance metric or a neighbour predicate between the individual text boxes, you could group the boxes and then determine their minimum bounding box, which is essentially what you are aiming for.

I guess DBSCAN could be a suitable candidate for the clustering algorithm, but more care would have to go into the design of the neighbor predicate - one idea could be that vertical distance could be treated differently than horizontal distance, etc.