HTML output of whole page
Try using renderer service instead as rendeer and drupal_render() is deprecated, e.g.

\Drupal::service('renderer')-&gt;renderRoot($content);



  Renders final HTML given a structured array tree.