1

I have an iframe, which includes <button onclick="print()">print</button>

var print = function(){
    parent.window.focus();
    window.print();
}

When I click on <button>, printing starts, but CSS is not included into printing. How can I force browser to include my CSS into printing?

Kajbo
  • 1,068
  • 3
  • 16
  • 31

2 Answers2

0

The CSS of the page inside the iframe must have the necessary print CSS media query in order to print as it is shown in the current browser.

i.e.

@media print {
    #my-element {
        color: red;
        /* all the styles you need */
    }
}   
Lolpez
  • 849
  • 8
  • 17
0

An iframe is a 'hole' in your page that displays another web page inside of it. The contents of the iframe is not in any shape or form part of your parent page.

See this answer https://stackoverflow.com/a/6495816/83542

Kildareflare
  • 4,590
  • 5
  • 51
  • 65