Exporting a Dashboard Into PDF with SisenseJS
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:
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!
Animesh Gupta
·2 years agoHi,
I wanted to use this. Can you please elaborate how to use this library.