tags:

views:

477

answers:

1

Hello,

I wrote a servlet to serve PDF using iText. Is there any way to disable printing/Copying/Saving from the browser end?

+1  A: 

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
Thanks 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
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.ThanksVish.
Vish