From: Robert H. <ha...@st...> - 2009-05-11 05:35:17
|
I was noticing that the applet is blank when printing a page. From what I can tell, it's a serious issue for all applets, and may not have an easy solution. but here's a slick way to do it in Firefox, as demonstrated at http://chemapps.stolaf.edu/jmol/docs/examples-11/jmol-flot.htm 1) Create two divs, one for an image and one for the applet: <div id="imagediv" class="printonly"></div> <div class="noprint"> <script type="text/javascript"> jmolInitialize(".","JmolAppletSigned0.jar") jmolApplet(["450","450"],....) </script> </div> 2) Now for styles we have: <style> @media print { .noprint {display:none} .printonly {display:block} } @media screen { .noprint {display:block} .printonly {display:none} } </style> And to get the image we use a link on the page that runs this JavaScript function. function setImage() { document.getElementById("imagediv").innerHTML = '<img src="data:image/jpeg;base64,'+jmolGetPropertyAsString("image")+'" />' } Now when the page is printed, the image is created and displayed, and the applet is hidden. It appears that the applet has printed. By the way, that base64 image business is broken in Jmol 11.7 -- only fixed in the next release, 11.7.35. Works like a charm, but only for Firefox, not Opera or MSIE. Bob -- Robert M. Hanson Professor of Chemistry St. Olaf College 1520 St. Olaf Ave. Northfield, MN 55057 http://www.stolaf.edu/people/hansonr phone: 507-786-3107 If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |