Você está na página 1de 3

function PrintWindow() { //if (navigator.

appName == "Microsoft Internet Explorer") { var PrintCommand = '<OBJECT ID="PrintCommandObject" WIDTH=0 HEIG HT=0 '; PrintCommand += 'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD7 05A2"></O B J E C T>'; document.body.insertAdjacentHTML('beforeEnd', PrintCommand); PrintCommandObject.ExecWB(6, 6); PrintCommandObject.outerHTML = ""; //} //else { //window.print(); } } function printit() { if (window.print) { window.print() ; } else if (document.all) { var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLAS SID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser.ExecWB(6, 6);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser.outerHTML = ""; } } <script type = "text/javascript"> function ClientSidePrint() { var w = 600; var h = 400; var l = (window.screen.availWidth - w) / 2; var t = (window.screen.availHeight - h) / 2; var sOption = "toolbar=no,location=no,directories=no,menubar=no,scro llbars=yes,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t; // Get the HTML content of the div var sDivText = window.document.getElementById("printReady").innerHTM L; // Open a new window var objWindow = window.open("", "Print", sOption); // Write the div element to the window objWindow.document.write(sDivText); objWindow.document.close(); // Print the window objWindow.print(); // Close the window objWindow.close(); } </script> <script type = "text/javascript"> function printit() { if (window.print) { window.print(); } else if (document.all) { var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLAS SID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; document.body.insertAdjacentHTML('beforeEnd', WebBrowser); WebBrowser.ExecWB(6, 6, 1); //Use a 1 vs. a 2 for a prompting di alog box

WebBrowser.outerHTML = ""; } } </script> ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language= javascript>window.open('/Parking/UI/Report/Ticket/RptVehicleCheckIn.aspx','Print Me','height=500px,width=500px,scrollbars=1,status=0');</script>"); //Server.Execute("~/UI/Report/Ticket/RptVehicleCheckIn.aspx"); //ClientScript.RegisterStartupScript(this.GetType(), "my Script", "<script language=JavaScript>reLoadPage();</script>"); //Response.Redirect("VehicleCheckIn.aspx"); ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language= javascript>window.open('/Parking/UI/Report/Ticket/RptVehicleCheckIn.aspx','Print Me','height=300px,width=300px,scrollbars=1');</script>"); //ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<scrip t language=JavaScript>PrintReceipt();</script>"); System.Net.IPHostEntry host; host = System.Net.Dns.GetHostEntry(Context.Request.ServerVariables["REMOTE_HOST" ]); string strSystemName = host.HostName; System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessSt artInfo(); startInfo.Arguments = "/h /t \"" + file + "\" \"PS801\""; startInfo.FileName = @"C:\Program Files\Adobe\Reader 9.0\Reader\Acro Rd32.exe"; ; //Replace this with the path of the Acrobat Reader executable file, i.e. AcroRd32.exe startInfo.UseShellExecute = true; System.Diagnostics.Process process = System.Diagnostics.Process.Star t(startInfo); //On some machines it takes 3 minutes to print a pdf file. If we don 't kill it after it's done, the Acrobat reader will stay in the memory. Then the user won't able to print next one. The solution is to set a timeout time. After the time elapsed, just kill the Acrobat reader. Forturenately on our server it only takes about 30 seconds. process.WaitForExit(30000); if (process.HasExited == false) { process.Kill(); } /* frame1.Attributes["src"] = file.ToString(); string test = @"\t 'D:\AppSource\Parking\Parking\app\Temp\" + fileNa me + ".pdf' 'POS801'"; string pathToExecutable = @"C:\Program Files\Adobe\Reader 9.0\Reader \AcroRd32.exe"; PrintHelper.RunExecutable(pathToExecutable, @"\t 'D:\AppSource\Parki ng\Parking\app\Temp\" + fileName + ".pdf' 'POS801'"); * */ var gAutoPrint = true; // Flag for whether or not to automatically call the prin

t function function printSpecial() { if (document.getElementById != null) { var html = '<HTML>\n<HEAD>\n'; if (document.getElementsByTagName != null) { var headTags = document.getElementsByTagName("head"); if (headTags.length > 0) html += headTags[0].innerHTML; } if (gAutoPrint) { if (navigator.appName == "Microsoft Internet Explorer") { html += '\n</HEAD>\n<' html += 'BODY onLoad="PrintCommandObject.ExecWB(6, -1);" >\n'; } else { html += '\n</HEAD>\n<BODY>\n'; } } else { html += '\n</HEAD>\n<BODY>\n'; } var printReadyElem = document.getElementById("printReady"); if (printReadyElem != null) { html += printReadyElem.innerHTML; } else { alert("Could not find the printReady section in the HTML"); return; } if (gAutoPrint) { if (navigator.appName == "Microsoft Internet Explorer") { html += '<OBJECT ID="PrintCommandObject" WIDTH=0 HEIGHT= 0 ' html += 'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD7 05A2"></OBJECT>\n</BODY>\n</HTML>'; } else { html += '\n</BODY>\n</HTML>'; } } else { html += '\n</BODY>\n</HTML>'; } var printWin = window.open("", "printSpecial"); printWin.document.open(); printWin.document.write(html); printWin.document.close(); if (gAutoPrint) { if (navigator.appName != "Microsoft Internet Explorer") { printWin.print(); } } } else { alert("Sorry, the print ready feature is only available in moder n browsers."); } }

Você também pode gostar