Wednesday, 26 January 2022

python or js code / library to export html elements of a Flask/Dash App

I have running a Flask Application with embedded Dash App. The application code is entirely written in python that renders html code. Now, I'd like to be able to export certain <html> elements to pdf.

python code for generating html:

import dash
from dash.dependencies import Input, Output, State
from dash import dcc
from dash import html, dash_table
import dash_bootstrap_components as dbc

html.Div([
 
     dbc.Row([
                     dbc.Card(
                                 [
                                     dbc.CardHeader("Median"),
                                     dbc.CardBody(
                                         [
                                             html.P(id="card"),
                                         ]

                                     ),
                                 ],
                                 id="stat",
                                 color="light",
                                 
                     ),

             ])
])

Here's the html generated by python code:

<div class="row">

  <div id="stat" class="card bg-light">
    <div class="card-header">Median</div>
  </div>

  <div class="card-body">
    <p id="card"></p>
  </div>

</div>

Is there a pythonic way of exporting html to pdf? I can also write Javascript if there is a way.



from python or js code / library to export html elements of a Flask/Dash App

No comments:

Post a Comment