Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

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 option

Please help

Thanks

 

  • Anonymous's avatar
    Anonymous
    2 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.

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

      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

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        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:

         

        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.

  • Anonymous's avatar
    Anonymous
    Not applicable

    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