executeJavaScript and window initialization order problem

Vaadin TestBench product has implemented this in roughly the following manner. You might use this to wait for vaadin to finish rendering before printing, but I have not tested it:


if (wnd.wrappedJSObject) {
		wnd = wnd.wrappedJSObject;
}

var connector = null;
if (wnd.itmill) {
	connector = wnd.itmill;
} else if (wnd.vaadin) {
	connector = wnd.vaadin;
}

var clients = connector.clients;
if (clients) {
			  for ( var client in clients) {
				  if (clients[client]
.isActive()) {
					  return false;
				  }
			  }
			  return true;
		  	} else {
		  		//A Vaadin connector was found so this is most likely a Vaadin application. Keep waiting.
		  		return false;
		  	}
	 }, timeout);

There is no separate rendering pipeline for static HTML or PDF. So your options are to either to 1) create the static html or pdf for printing with some other tool, 2) use long enough setTimeout or 3) get the above wait for vaadin javascript approach to work.