I have a powerbi report embedded to my webpage. What I need is to add an "export" button to my page and export the report to the PDF when the button is clicked. How can I achieve this? People online advises using report.print() or window.print(), but both did not work for me.

var reportContainer = document.getElementById('reportContainer');

var report = powerbi.embed(reportContainer, config);
var report2 = powerbi.get(reportContainer);

console.log(report);  --returns the report
console.log(report2); --also returns the report

report.print(); --nothing happens
report2.print(); --nothing happens

var saveAsParameters = {
    name: "newReport"
report2.saveAs(saveAsParameters); --nothing happens report.saveas also nothing happens

window.print(); --it prints a blank page.

I found this but did not help: Print/Generate PDF of embedded power bi report

Please note that I know I can export the report to pdf via PowerBI Desktop but I need to do it on my custom web page.

Any help would be so appreciated.

0 Answers