cancel
Showing results for 
Search instead for 
Did you mean: 
OleksiiDemianyk
Sisense Team Member
Sisense Team Member

Exporting a Dashboard Into PDF with SisenseJS

This article explains how to develop the functionality of generating PDF with the shown widgets when Sisense dashboard is embedded with SisenseJS. 

When the dashboard is exported into PDF, the report is generated on the Sisense server. When a dashboard is embedded with SisenseJS, then developers can create their own layout, which can differ from the layout created by the dashboard’s designer. SisenseJS does not provide an option to export the shown widgets to PDF, because Sisense will not be able to render the same layout that is used in the parent application. Nevertheless, the shown dashboard can be easily exported into PDF. For exporting we need to use the external library [html2pdf.js]. More information about this library can be found at this link. This library should be added to the page:

 

 

 

 

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>

 

 

 

 

Once this library is loaded and Sisense widgets are rendered on the page, you can call methods from this library in order to generate PDF reports. To utilize the methods of this library, I created a function exportToPDF() and variable [opt]. Variable [opt] stores settings that will be used to initiate exporting to PDF. In the sample below, the returned file will be named “myfile.pdf”. Function exportToPDF() expects a DOM element that contains the rendered widgets. HTML of the given element will be rendered in the returned PDF:

 

 

 

 

const opt = {
    filename: 'myfile.pdf', //File name
};

function exportToPDF(lmnt) {
    const dashboardContainer = document.getElementById(lmnt);
    html2pdf().set(opt).from(dashboardContainer).save();
}

 

 

 

 

Sample of this logic execution:

 

 

 

 

exportToPDF('sisenseApp');

 

 

 

 

 In the generated PDF the widgets will be placed as the developer placed them.

Using this approach you can easily implement the functionality of generating PDF reports. Feel free to use this logic and modify them according to your needs! 

Rate this article:
Comments
angupta
7 - Data Storage
7 - Data Storage

Hi, 
I wanted to use this. Can you please elaborate how to use this library.

Version history
Last update:
‎06-07-2023 02:15 PM
Updated by: