Multipage Download Option for Dashboards

I have encountered an issue where I need to create a download button that takes a snapshot of my dashboard and downloads the dashboard with all the graphics as a PDF with multiple pages. However, based on the research I have done, Panel does not natively support this (the multi pagination). I have tried other libraries such as WeasyPrint, PDFKit and for Report Lab, I need to reconstruct the full report again which feels like duplicate work.
Is there a library I can use to achieve multi page pdf download without compromising on the scale or size?

2 Likes

Can you share some code?

I imagine you could store references of the images in a list or dict and loop through, render them, and add to PDF.

Thanks ahaung, let me share some code. It would be amazing if I am able to split into pages

In the past I used jinja2 to automatically write multipage reports by generating LaTeX files. I am curious to see better solutions!

Thanks to the both of you. But when you do not have a template and say your dashboard main view is defined by pn.Column, that allows for a natural page break when you windows.print(). However, when you have a long flowing dashboard that is inside a template, in this case a Fast List Template, and contains widgets such as the tabulator widget, it does not break the dashboard into pages when you window.print(). I have tried enforcing that using the @media print in css but that does not help. See below. Does the jinja templating work with Panel templates?

@media print {
/* Make the template main content expand instead of being a scrollable box */
.template-main, .bk-root, .panel-card, .panel-layout, .panel-holoviews {
overflow: visible !important;
height: auto !important;
max-height: none !important;
}

    /* Force visible page breaks where we place .pagebreak elements */
    .pagebreak {
        display: block;
        page-break-after: always;
        break-after: page;
    }

    /* Allow tables and tabulator to break across pages */
    table, .tabulator, .tabulator-tableholder {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* If header/sidebar cause trouble, hide sidebar in print and let header flow */
    .template-sidebar { display: none !important; }
    .template-header, header, .app-header {
        position: static !important;
    }

    /* Sometimes help: ensure body/html expand */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }
}