1

My web system has print invoice function. I need to prevent the user from:

  • Editing the invoice in a web browser (F12)
  • Saving the invoice to local

Please give me some solutions. My invoice is render in html.

Scopey
  • 6,269
  • 1
  • 22
  • 34
Thanh Binh
  • 11
  • 5
  • I wonder if there is a real solution to prevent user from editing the invoice. Is serving the invoice in PDF format OK for you? Then there are ways to print the PDF invoice without downloading it first. – qtuan Apr 29 '16 at 04:30
  • Reading your question again, you need to prevent saving invoice to local as well. Then PDF would not be the solution. – qtuan Apr 29 '16 at 04:41
  • Attempting to prevent a user from making changes to your website is an impossible battle that's not worth any time. You need to ask yourself if this is really a concern at all. – Scopey Apr 29 '16 at 04:59
  • This is symptomatic of a much larger issue at work. If someone is going to have the incentive to modify a webpage in order to spoof something, they will likely be willing to also print the invoice, scan it, edit it, and reprint the edited version. The better question is probably, why is there an incentive for them to change the invoice, and what systems can you put in place to reduce the effectiveness of them modifying the invoice? – BayssMekanique Apr 29 '16 at 06:09
  • The first idea I thinks is pdf but I don't have solution for preventing download and I think it not solution for my problem. How about rendering invoice in html5 canvas ? – Thanh Binh Apr 29 '16 at 07:52

1 Answers1

0

Editing the invoice in a web browser (F12)

Using "browser hacks" to disable a web browser's developer tools, to prevent users from editing the invoice for their own purpose is not a sound strategy. The code that would otherwise block or limit the use of the developer tools keeps changing as browsers are updated.

But, if your still interested in pursuing this path, have a look at this question: How does Facebook disable the browser's integrated Developer Tools?.

Saving the invoice to local

Acknowledging that everything viewed on browser, had to be downloaded in the first place to be viewed.

You can't really stop users from saving a copy of the invoice, you can however, make it harder for regular users to save a copy to their documents folder or other folder they choose for that matter.


Anyway, assuming you can make the invoices available in PDF format, have you considered using the embeddable Google document viewer?

It allows you to view a number of documents within the confines of a web browser, sorry I cannot find the documentation online, but its usage is pretty straightforward.

<iframe src="//docs.google.com/gview?url=http://example.com/invoice/123.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>

Fiddle

Replace http://example.com/invoice/123.pdf with the URL to the particular invoice.

This would allow users to view the invoice, yet prevent normal users from editing and/or saving it for later use.

However, it wouldn't prevent a user with the same knowledge required to make of use of the developer tools, from viewing the source and grabbing the URL for the invoice from the source of that iframe.

Community
  • 1
  • 1
Fábio Antunes
  • 16,984
  • 18
  • 75
  • 96