Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GSP
Frequent Visitor

How to enable 'Print' option in iframe

HI,

 

We embeded our Power Bi reports using iframe. How to enable 'Print' option here. We have below esport option and that is generating empty file. 

Export optionExport option

Please help

Thanks

 

1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @GSP ,

Sorry, so far, to my knowledge, this may not be achieveable in PBIRS.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
GSP
Frequent Visitor

Hi,

Noted. Thanks.

 

We are trying the following code shared by Microsoft Copilot

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Power BI Embedded Report</title>
<!-- Include Power BI JavaScript library -->
<script src="https://microsoft.github.io/PowerBI-JavaScript/dist/powerbi.min.js"></script>
</head>
<body>
<!-- Embed the report using an iframe -->
<iframe id="embeddedReport" width="800" height="600" src="https://app.powerbi.com/reportEmbed?reportId=<your-report-id>&groupId=<your-workspace-id>&config=<your-embed-config>"></iframe>

<!-- Custom buttons for print and export -->
<button onclick="printReport()">Print Report</button>
<button onclick="exportToPDF()">Export to PDF</button>

<script>
// Initialize Power BI report
const embedConfig = {
type: 'report',
id: '<your-report-id>',
embedUrl: 'https://app.powerbi.com/reportEmbed',
accessToken: '<your-access-token>',
tokenType: models.TokenType.Embed,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: false
}
};

const reportContainer = document.getElementById('embeddedReport');
const report = powerbi.embed(reportContainer, embedConfig);

// Custom print function
function printReport() {
// Capture a screenshot of the report area (you can use external libraries for this)
// Open the browser's print dialog
window.print();
}

// Custom export function (to PDF)
function exportToPDF() {
// Use Power BI REST API to trigger export
// Example: https://api.powerbi.com/v1.0/myorg/groups/<your-workspace-id>/reports/<your-report-id>/ExportTo
// Implement the necessary logic to handle the export
console.log('Exporting report to PDF...');
}
</script>
</body>
</html>

 

Please suggest how can we get the below highlighted access token

const embedConfig = {
type: 'report',
id: '<your-report-id>',
embedUrl: 'https://app.powerbi.com/reportEmbed',
accessToken: '<your-access-token>',
tokenType: models.TokenType.Embed,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: false
}

 

Please help

 

Thanks

Hi @GSP ,

Please refer below official documents: 

Permission tokens needed to embed a Power BI app - Power BI | Microsoft Learn , 

Generate an embed token in Power BI embedded analytics - Power BI | Microsoft Learn

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-binbinyu-msft
Community Support
Community Support

Hi @GSP ,

Sorry, so far, to my knowledge, this may not be achieveable in PBIRS.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

Thank you for your reply.

 

We are embedding our Power Bi reports into our web application in iframes. We used the option File-> Embed Report-> Website or Portal

 

We understand that

If we need to print reports we need to login to app.powerbi.com, need to export the needed reports and need to print. 

We do have the possibility to set up 'Print' option in our website where we embeded our Power Bi reports

 

Could you please confirm this

Thanks

 

 

Hi @GSP ,

When you embed a report in a secure portal or website, user need sign in and need license and permission to view the report, and don't show 'Print' options in the report, please refer below screenshot:

vbinbinyumsft_0-1709106204850.png

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

We have license. We are able to sign in and view the embeded report in website. Our client's requirement to provide a 'Print' option in the website where we embededed our report. So we are checking the posibilities here. Hope this clarifies.

Thanks

Hi @GSP ,

Sorry, so far, to my knowledge, could not set for 'Print' option when you embed a report in a secure portal or website.

Please try to embed report in sharepoint online pages, all toolbars will be show in report.

vbinbinyumsft_0-1709107656806.png

 

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HI,

 

Thank you for your reply. We are checking this for one of our client. So do we have any correct link to confirm this is not possible. Please help. 

 

Also, from the following reference links we noticed that we need to have ‘Pro’ account. Is this correct.

https://community.fabric.microsoft.com/t5/Developer/REST-API-Get-Access-Token/m-p/1898039#M29951

https://learn.microsoft.com/en-us/power-bi/developer/embedded/register-app?tabs=customers

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.