My answer is based on the ones given by @Porschiey and @Paul Roub with a slight addition.
Their given solution did work for me in most cases except for some where the <div>
that I wanted to print had a CSS set to position: fixed
. In the resulting print, this would usually contain only the content that was able to fit in the actual size of the <div>
on the loaded page.
So, I also had to change the position CSS attribute to something like relative
so that everything could get printed. So, the resulting CSS that worked for me is this:-
{ display: block; /* Not really needed in all cases */ position: relative; width: auto; height: auto; overflow: visible;}