You are relying on "printwindow.document.body.onload=self.print();" line being executed before the child document finishes loading. I don't think you can be guaranteed that.
Here's an idea: prepare HTML or a page that has nothing but the page you need in an iframe. This page will have body.onload=self.print().