0

How can i combine this $windows.open() and $windows.print() so when user click on button to open new windows with some specific content and that have option for print?

EDIT: I figure out to use $window.open().print() to open window with print option but how to fill out with specific content

None
  • 8,817
  • 26
  • 96
  • 171

1 Answers1

0

You CAN NOT specify the content to print. The print function will print the current page.

However, you can use css mediatype as a workaround.

First, create a div containing all the content you want to print, use the css to make it disappear.

 #printDiv { display: none }
 <div id="printDiv"></div>

Then use the css mediatype to hide all other elements, display only what you want to print:

@media print {
  * { display: none}
  #printDiv {display: block}
}

Another solution is using an iframe as specified here: How do I print part of a rendered HTML page in JavaScript?

Community
  • 1
  • 1
Huy Hoang Pham
  • 4,107
  • 1
  • 16
  • 28