I wrote a servlet to serve PDF using iText. Is there any way to disable printing/Copying/Saving from the browser end?
Asked
Active
Viewed 2.1k times
1 Answers
4
Here's a thread that provides the relevant magic API invocation. The idea is that you have to encrypt the PDF in order to protect various user operations.
PdfReader reader = new PdfReader("my-old-file.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("my-new-file.pdf"));
stamper.setEncryption("my-owner-password".getBytes(), "my-user-password".getBytes(),
PdfWriter.AllowPrinting | PdfWriter.AllowCopy, PdfWriter.STRENGTH40BITS);
stamper.close();

Jonathan Feinberg
- 44,698
- 7
- 80
- 103
-
1Thanks for the reply. I used this example to disable printing and coping.But only Printing menu is disabled. Still i can Save the pdf. Any idea? – Madhu Dec 20 '09 at 16:35
-
Hi, For me, this code works only if we have Adobe Reader 8.x installed. I upgraded to Adobe Reader9.3 and it is not disabling the print option. Please let me know. Thanks Vish. – Blue Sky Jun 17 '10 at 08:06
-
what about iText7? – Lefteris Bab Apr 12 '18 at 05:43