Search code examples
javascriptasp.net-mvcprintingwindows-servicesapi-design

Send a file to a printer to print when user click print button. But the user MUST NOT be able to Download PDF before Printing


Users request to print reports that are generated on the server side. These reports are sent back as PDF files. There is no need to open these files before printing them. I am using asp.net mvc 5 with js/jq.

NOTE : I KNOW BROWSERS DOES NOT LET US TO DO THIS DUE TO SECURITY REASONS but in my case only people with access can print the report we just need to prevent them from changing the content.

I have already tried different methods but seems chrome and other popular browsers do not let websites send print requests to printer without going through the print popup(ctrl + p) on chrome. I do not mind the print popup so the user can still initiate the print.

BUT THE PROBLEM IS THERE IS AN OPTION TO SAVE/DOWNLOAD THE FILE on the print popup(ctrl + p). There are security issues because the user can use a PDF editor tool and change valuable information like prices, bank account details etc and print the Document.

I tried print.js (https://printjs.crabbly.com/) but it did not work as it also opens print popup and save the option to save.

Currently we send the files to a api send them to printers through api's. But there are printers that does not support api requests. Which makes us to make the user choose the printer from the browser and print.

I am pretty much open to any type of suggestions and solutions. solution can be client side / server side / windows services etc anything pretty much. Just the user should not be able to tamper with the file before printing.

EDIT:

For some Context what happened was a user changed the account details of a invoice and tried to pocket some $$. So the management asked us to not let the user see the PDF and print it directly.

But as in the comments a DETERMINED user can still scan it can edit stuff and print again. So i guess we cant do anything about the DETERMINED users.

But can we do something about the UN-DETERMINED users..?

The people who uses the system and have access to those invoices are old people 40+ (70s-80s people) with minimal computer knowledge so its hard to say they will get ideas to scan and edit lol.

The harder it is to change the data the less likely it will give people ideas to change it. I think that's what the management is trying to do.

And i dont think if we can print a password protected PDF. So that approach wont work as well.

If anything doesnt work i can tell the management that. But if there is anything big or small i can do to hinder people from changing pdf content i am up to implement it.

EDIT 2 :

The solution im currently trying to implement is to Install a windows app in the users pc and send the PDF to it THROUGH the client side(browser) and print from that app.


Solution

  • The solution im currently trying to implement is to Install a windows app in the users pc and send the PDF to it THROUGH the client side(browser) with URL Protocols and print from that app.