Silent Print From Client side IE

Hi,


I tried print pdf from browser via javascript.

it prints with dialog box . i tried to skip this dialog box but failed in doing so.

i tried several codes like

1 -- // this also opens dialog box

  

function print1()
{
if (navigator.appname == "microsoft internet explore")
{
var printcommand = '<object id="printcommandobject" width=0 height=0 classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2"></object>';
document.body.insertadjacenthtml('beforeend', printcommand);
 document.all.printcommandobject.execwb(6,-1);
printcommandobject.outerhtml = "";
}
else {
window.print();
}
}
</script>

<button onclick=print1()>Try it</button>

2-this is second code which i tried

<script>
function btn_print_onclick() {
  factory.printing.header = "This is MeadCo";
  factory.printing.footer = "Printing by ScriptX";
  factory.printing.portrait = false;
  factory.printing.leftMargin = 1.0;
  factory.printing.topMargin = 1.0;
  factory.printing.rightMargin = 1.0;
  factory.printing.bottomMargin = 1.0;
  factory.printing.Print(false);
}
</script>

    
</head>
<body>
   <button onclick="btn_print_onclick()">Print report</button>
</body>

3 - also tried some links but they also didn't work for me

http://forums.asp.net/t/1364879.aspx?Avoid+Print+dialog+box+while+printing+webpage

http://www.webdeveloper.com/forum/showthread.php?174029.html

http://justtalkaboutweb.com/2008/05/09/javascript-print-bypass-printer-dialog-in-ie-and-firefox/

http://scriptx.meadroid.com/community-support/community-forum/general/2014/1/the-problem-of-scriptx-in-ie8.aspx


http://codeverge.com/asp.net.getting-started/avoid-print-dialog-box-while-printing/726740

https://gist.github.com/cchitsiang/7349218

http://www.codeproject.com/Questions/784656/Printing-in-one-click-I-dont-want-print-setup-dial

any help will be appreciated.

Thanks

Sushil

July 27th, 2015 1:10pm

Hi,

This is the forum to discuss questions and feedback for Microsoft Visio that one suit of MS Office, I recommend you post the question to the MSDN forum for JS

https://social.msdn.microsoft.com/Forums/en-US/home?forum=jscript

https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=netfxjscript

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

George Zhao
TechNet Community Support

Free Windows Admin Tool Kit Click here and download it now
July 27th, 2015 10:14pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics