Plots to PDF file

Hi, I am using the Django application to generate some graphs using Plotly so

I tried to generate a pdf file of the following plots page
my HTML page is:

        <center> <p class="lead"><strong><em>&nbsp;All Plots&nbsp;</em></strong></p></center>
        <div class="row">
            <div class="col-md-6" >
                {{ sunburst|safe}}
            </div>
        
            <div class="col-md-6" >
                {{ sunburst2|safe}}
            </div>
        </div>

and my url.py :

    path('export_pdf/', views.export_pdf, name='export_pdf'),

and the views.py;

def export_pdf(request):
    df = px.data.gapminder().query("country=='Canada'")
    fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
    df2 = px.data.gapminder().query("continent=='Oceania'")
    fig2 = px.line(df2, x="year", y="lifeExp", color='country')

    chart = fig.to_html()
    chart2 = fig2.to_html()
    context= {
        'sunburst':chart,
        'sunburst2':chart2,
        }
    return render(request, 'Home/Reporting/part_pdf.html',context)

I tried some code from this page but I can’t generate the file any help?

are there any other methods to do that (html page with plots and tables)?

All my best