At a prior company I worked at, they had the requirement to allow pretty sophisticated and seamless “download report as pdf” functionality. So exactly what you’re asking about, more or less.
The solution they came to was to have the “Print to PDF” button call an endpoint that launched a headless chrome instance that printed the page, and to have a pile of print media css rules. It worked… Far better than it really should have.
At a prior company I worked at, they had the requirement to allow pretty sophisticated and seamless “download report as pdf” functionality. So exactly what you’re asking about, more or less.
The solution they came to was to have the “Print to PDF” button call an endpoint that launched a headless chrome instance that printed the page, and to have a pile of print media css rules. It worked… Far better than it really should have.