Home   Archive   Permalink



Silent Firefox Printing

Don't recall this silent printing method in the Rebol documentation.
    
First, one needs JS Print Setup extension for Firefox.    
    
Then, add this to the <body> tag: onload=jsPrintSetup.print()
    
If it does not print when the page is loaded, Firefox silent printing must be enabled.
    
http://www.blueboxonline.com/?showkm&global[uid]=392-%28%29-Enabling-silent-printing-in-Firefox has the instructions, thanks!
    
When set, do browse %print.html in Rebol. The page will print silently. No buttons to push, no dialogues to negotiate. And the parameters of the Java script code can be modified with Rebol too.
    
This is the test page %print.html:
    
<html>
<head>
    <title>Test Print without prompt</title>
    <style>body {font-family:verdana,arial;font-size:10pt;background:white;} div {width:600px;border:3px
    
solid #ccc;padding:3px;}</style>
    <script type="text/javascript">
    function print_doc()
    {
        jsPrintSetup.setOption('orientation', jsPrintSetup.kPortraitOrientation);
        // set top margins in millimeters
        jsPrintSetup.setOption('marginTop', 15);
        jsPrintSetup.setOption('marginBottom', 15);
        jsPrintSetup.setOption('marginLeft', 20);
        jsPrintSetup.setOption('marginRight', 10);
        // set page header
        jsPrintSetup.setOption('headerStrLeft', 'My custom header');
        jsPrintSetup.setOption('headerStrCenter', '');
        jsPrintSetup.setOption('headerStrRight', '&PT');
        // set empty page footer
        jsPrintSetup.setOption('footerStrLeft', '');
        jsPrintSetup.setOption('footerStrCenter', '');
        jsPrintSetup.setOption('footerStrRight', '');
        // Suppress print dialog
        jsPrintSetup.setSilentPrint(true);/** Set silent printing */
        // Do Print
        jsPrintSetup.print();
        // Restore print dialog
        jsPrintSetup.setSilentPrint(false); /** Set silent printing back to false */
    
    }
</script>    
</head>
<body c<html>
<head>
    <title>Test Print without prompt</title>
    <style>body {font-family:verdana,arial;font-size:10pt;background:white;} div {width:600px;border:3px
    
solid #ccc;padding:3px;}</style>
    <script type="text/javascript">
    function print_doc()
    {
        jsPrintSetup.setOption('orientation', jsPrintSetup.kPortraitOrientation);
        // set top margins in millimeters
        jsPrintSetup.setOption('marginTop', 15);
        jsPrintSetup.setOption('marginBottom', 15);
        jsPrintSetup.setOption('marginLeft', 20);
        jsPrintSetup.setOption('marginRight', 10);
        // set page header
        jsPrintSetup.setOption('headerStrLeft', 'My custom header');
        jsPrintSetup.setOption('headerStrCenter', '');
        jsPrintSetup.setOption('headerStrRight', '&PT');
        // set empty page footer
        jsPrintSetup.setOption('footerStrLeft', '');
        jsPrintSetup.setOption('footerStrCenter', '');
        jsPrintSetup.setOption('footerStrRight', '');
        // Suppress print dialog
        jsPrintSetup.setSilentPrint(true);/** Set silent printing */
        // Do Print
        jsPrintSetup.print();
        // Restore print dialog
        jsPrintSetup.setSilentPrint(false); /** Set silent printing back to false */
    
    }
</script>    
</head>
<body onload=jsPrintSetup.print()>
<center>
<div>
The document starts here ...<br/>
This is test foo<br/>
This is test<br/>
This is test<br/>
<br/><br/>
<input type="button" value="Print Now" onClick="print_doc();"/>
</div>
</center>
</body>
</html>>
<center>
<div>
The document starts here ...<br/>
This is test foo<br/>
This is test<br/>
This is test<br/>
<br/><br/>
<input type="button" value="Print Now" onClick="print_doc();"/>
</div>
</center>
</body>
</html>
    
(on Firefox 26 as default browser, XP)

posted by:   Felix       12-Sep-2014/20:38:13-7:00