0

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/PNG when the button is clicked send it to my backend, so I can mail it. How can I achieve this?

Tried libs that convert html to pdf but since is an iframe it won't load the content due to CORS.

Tried

var element = $('#reportContainer')[0];
var report = powerbi.get(element);
report.print()

But this will open the print page by the browser and, thus, I'm not able to get what has been generated.

candiani
  • 29
  • 7

1 Answers1

0

You can't create any button to export in the powerbi embedded report. If you want a button then create a button in report before embedding, So when the button is clicked you can apply a buttonClicked event and it should trigger an export job. After the job is completed you can able to export the report into pdf and you can also download.

  1. To export the customized Power BI Embedded report as pdf or ppt, You need exportToFile API. Before using the API, Make sure the admin tenant settings are enabled by default for export reports.

  2. Steps to Export:
    i. Sending an export request: An export request is sent for a specific page and will return exportID.
    ii. Polling: Check whether the request file is ready to export and will return URL.
    iii. Getting the file: Use the URL from Polling to get the exported file and you will get the file stream. When you have the file stream you can email it or use it to download the exported reports.

You can find the reference and the sample code from the link. https://learn.microsoft.com/power-bi/developer/embedded/export-to#using-the-api

Rohit Ronte
  • 129
  • 3