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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Custom HTML Button to Print Embedded Report

I have quite a few embedded reports that users need to be able to click a button and print the full report. I have GCC so I cannot use Power Automate. I saw where I could add the "HTML Content" visual to add a customized print button. I added that then added the following measure for the visual:

 
HTMLButton =
"<html>
  <head>
    <title>Print Button</title>
    <style>
      .print-button {
        background-color: #a0d1ff;
        border-color: #118dff;
        border-style: solid;
        border-width: 3px;
        color: black;
        padding: 4px 30px;
        text-align: center;
        display: inline-block;
        font-family: Segoe
        font-size: 9px;
        cursor: pointer;
        margin: 4px 2px;
      }
    </style>
  </head>
  <body>
  <div id='report-container'></div>
  <div class='print-button' onclick='printReport()'><b>Print</b></div>
    <script>
    function printReport() {
    var element = document.getElementById('report-container');
    var report = powerbi.get(element);
    report.print();
    }
    </script>
  </body>
</html>"
 
The button looks great but when I click on it from within the embedded report, nothing happens. Any ideas how to fix this, or any ideas on how to print an embedded report?
1 REPLY 1
dm-p
Super User
Super User

Hi @Anonymous,

 

HTML Content doesn't support scripting, and I don't have any plans to include support for this, as I can't supply any tools for debugging scripts if they fail. Custom visuals also have very limited abilities due to the sandboxing that Microsoft imposes upon them for security reasons, so there's a lot of Javascript that won't work and that can make it more confusing for anyone attempting to reproduce something inside it.

 

Also because custom visuals are sandboxed iframes, they don't know anything about the rest of the report. Even if you could action the print dialog via scripting, you would only be able to print the visual itself and not the rest of the visuals on the report page.

 

I'm not very familiar with Power BI embedded, but you would likely need to code the functionality to an element (e.g. a button) within the page that hosts your report. It looks like there is a print method that can be used. The folks that work with Power BI Embedded frequent the Developer forum on these community boards, so you may have more luck posting your request there.

 

Regards,

 

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.