OK, I see. Firefox doesn't print anything, and MSIE trashes the resolution
but at least prints something. So now I have this working in MSIE, opera,
and firefox using:

<style>
@media print {
    .noprint {display:none}
    .printonly {display:block}
}
@media screen {
    .noprint {display:block}
    .printonly {display:none}
}
</style>


That appletdiv has no class initially.

Then, in the code I have:

var appletPrintable = (navigator.appName != "Netscape") // Sorry, I don't
know how to check for this

$(function () {
    // document ready function
    if (!appletPrintable)$("#appletdiv").addClass("noprint")
})

function setImage() {
    if (appletPrintable)return
    var image = jmolGetPropertyAsString("image")
    var html = '<img src="data:image/jpeg;base64,'+image+'" />'
    document.getElementById("imagediv").innerHTML = html
}


On Mon, May 11, 2009 at 12:35 AM, Robert Hanson <[email protected]> wrote:

> 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
>



-- 
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
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to