user3378165 user3378165 - 1 year ago 149
Javascript Question

Send documents to printer using JavaScript?

On My MVC application, I have a View with a list of PDF documents.
I have to allow the user to check the documents he wants and to send the selected documents to the printer.

This is my View:
enter image description here

After the user choose the documents he wants to print I check which documents are selected, and get their paths in an array with Javascript and Knockout:

var mappedArray = $.map(self.checkedDocs(), function (item) { return crm.controlRecord().pdfLoc() + item.pdfDocloc() });

An Example of an array:

["\\aaa\bbb\ccc\docs\2016\03\22\test1.pdf", "\\aaa\bbb\ccc\docs\2016\03\22\test2.pdf", "\\aaa\bbb\ccc\docs\2016\03\22\test3.pdf"]

How can I send these documents to the user's printer on client side?

I have this code that works great when I print a HTML table, but I'm not sure how to do it with documents.

self.print = function () {
var divToPrint = document.getElementById('tableToprint');
newWin ="");

Please advise.

Answer Source

This scenario is not possible.

The user can't print documents that are on the website server, he first has to download the documents then he will be able to print them.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download