Render HEEX template with given (root) layout to string

Hello,
I would like to ask, if there is a better way to render .html.heex files to string WITH layouts?

My use case is that in controller I need raw HTML to later process into PDF.
Here, building on top of the starter project, I have a working solution (by rendering page and layout myself):

defmodule PhoenixTemplatesPocWeb.PageController do
  use PhoenixTemplatesPocWeb, :controller

  alias PhoenixTemplatesPocWeb.Layouts
  alias PhoenixTemplatesPocWeb.PageHTML

  def home(conn, _params) do
    # The home page is often custom made,
    # so skip the default app layout.
    render(conn, :home, layout: false)
  end

  def home_pdf(conn, _params) do

    rendered_content =
      %{}
      |> PageHTML.home_pdf()
      |> Phoenix.HTML.Safe.to_iodata()
      |> IO.iodata_to_binary()

    rendered_pdf =
      %{
        inner_content: rendered_content
      }
      |> Layouts.root_pdf()
      |> Phoenix.HTML.Safe.to_iodata()
      |> IO.iodata_to_binary()

    text(conn, rendered_pdf)
  end
end

Thanks.