Black Lives Matter. Please consider donating to Black Girls Code today.

How to get raw HTML from dash_html_components

I am trying to convert html to pdf and for that I need the raw html. Is there a way to get that from the dash HTML object?

There’s not currently a way to do this within a Dash app itself. It would be possible to write a function to generate the HTML structure for a component tree that was composed entirely of dash_html_components, however as soon as you add dash_core_components (or other custom components) this won’t work as you’ll need to render them in a web client.

There was a thread about ways of getting the HTML manually, but I can’t ind it unfortunately. I think the conclusion was just to use 'Save As.

If you want to do it programatically, I would suggest using Chrome Headless to generate PDFs. This has been used by someone else on this forum with success.