-3

I have used opening pdf using following code.

try
{
  File file = new File("Sample.pdf");
  java.awt.Desktop.getDeskTop().open(file);
  System.out.println("File opened successfully");
}catch(Exception ex)
{
  System.out.println("Error occurred: "+ex);
}

Now i want disable save,save as,print option in the pdf file before opening.I have tried this link.but it wont work.

It throws following error occur.

Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/cms/Recipient

Caused by: java.lang.ClassNotFoundException: org.bouncycastle.cms.Recipient
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

How to disable save,save as,print option for given pdf file?

Community
  • 1
  • 1
Ami
  • 4,241
  • 6
  • 41
  • 75

1 Answers1

0

You missd the most importnat part of the link you attached, you need to use the PdfWriter static fileds, i am not sure it support all your needs but at least some of them like ALLOW_PRINTING.

CloudyMarble
  • 36,908
  • 70
  • 97
  • 130