0

We have a requirement to print the page without print dialog.

We have tried the following JavaScript:

function PrintIt() {

    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
    document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
    WebBrowser1.ExecWB(7,2); // Error: Object doesn't suport this property or method

    return false;
} 

The above code is working in normal ASP.NET application. But its not working in a Sharepoint Page and giving the error metioned above

3

The easiest, non intrusive approach i usually recommend for printing, is having a dedicated CSS for this purpose that would hide unwanted navigation and other controls.

Add a new CSS link with media="print" and the browser will take care of the rest.

<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/print.css" media="print" />
1

That does not depend on Sharepoint, but on HTML, Browsers and Security. I assume you are searching for an solution for IE-Browsers only? I would expect that it should be possible with ActiveX, .NET, Silverlight somehow.

Perhaps, if you know which printer is it, you could send an AJAX Request to your server which prints than that page.

But IMHO it is a very uncommon task and you should be carefull with just printing a page. So there is no chance to print to pdf, email etc. I think it is not a good thing, to hide the print dialog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.