Forum Discussion
How to enable 'Print' option in iframe
- Anonymous2 years ago
Hi Anonymous ,
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,
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
- Anonymous2 years agoNot applicable
Hi Anonymous ,
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.