I have developed many web applications which contains print functionality. I usually rely on any third party library for doing this. Not because I don’t know any other method but because having full control on print content in my hand. Peoples used to ask me why I don’t use window.print. This is simplest way to print any content on web pages or in form of string.
Biggest problem with window.print is that it shows unexpected behaviour in some browser and on major of them is Firefox. When you simply print using window.print and use it in firefox then it will not work.