0

I have a print function in my webpage, and I have a piece of JavaScript appended at the header.

 <script type="text/javascript">
 function printPartOfPage(elementId)
 {
 var printContent = document.getElementById(elementId);
 var windowUrl = 'about:blank';
 var uniqueName = new Date();
 var windowName = 'Print' + uniqueName.getTime();
 var printWindow = window.open('', '', 'left=50000,top=50000,width=0,height=0');

 printWindow.document.write(printContent.innerHTML);
 printWindow.document.close();
 printWindow.focus();
 printWindow.print();
 printWindow.close();
 setTimeout(function ()
 {
 printWindow.print();
 }, 500);
 }
 </script>

And the button use to trigger the Javascript.

 <asp:Button ID="btnSumbit" runat="server" Text="Print" OnClientClick="JavaScript:printPartOfPage('modaltable');" />

My problem is, is there any workaround to determine whether a user has successfully printed, or at least has sent the print job to the printer? Will the window.print() returns any value once the user click the "Print" button on the print UI? Because I need the result to determine whether the user has really printed the documents out and to do further validation in my database.

Chuah Cheng Jun
  • 243
  • 1
  • 3
  • 17
  • 1
    You're not going to be able to get that information unless you have access to the print driver on the client. You can set a global variable and keep track of the number of times the print button has been pressed, but in terms of successfully printed items you cannot get this information. – Steven Mays Apr 25 '16 at 15:39
  • Mind elaborate on how to get the value whether is the Print button pressed? :D @StevenMays It is ok if I can't get the value for a successful printed job. – Chuah Cheng Jun Apr 25 '16 at 15:42
  • Sure, have it call a method on your back end that does N+1 and saves it into a database/xml/text file. You'll probably want to save the user too. I don't know your particular data/service layer but it should be a fairly easy problem to solve. – Steven Mays Apr 25 '16 at 15:45
  • 1
    This might help you : http://stackoverflow.com/questions/18325025/how-to-detect-window-print-finish – Zaki Apr 25 '16 at 16:01

0 Answers0