I know you can use window.print() to print the current page... but what I want to know is can I build a document using javascript in order to populate it with data and print it
There is a simple solution available no need to write a function and that is - window.print()
whereever you want to use it just put - onClick="window.print();"
Example
Print
I testes it every browser and it works like a charm !