Question

Nous avons une obligation de protéger les fichiers PDF à l'aide d'un mot de passe. Y a-t-il des outils open source basés sur Java qui nous aidera à cet égard?

Était-ce utile?

La solution

Je recommande d'utiliser le iText bibliothèque PDF java.

À l'intérieur iText, il y a une classe appelée PdfEncrypter ce qui devrait vous laisser le mot de passe protéger un fichier PDF.

Autres conseils

Vous pouvez facilement faire le mot de passe fichier protégé pdf en java ...... faire, vous aurez besoin de deux jar addtional / lib bctsp-jdk16-1.46.jar et bcprov-jdk16-1.46.jar avec le itextpdf -5.2.1.jar.
Téléchargez tous les bocaux d'ici Télécharger Jars

En outre ci-dessous est l'extrait du code

private static String USER_PASSWORD = "password";
private static String OWNER_PASSWORD = "naveen";
public static void main(String[] args) throws IOException {

    Document document = new Document();
      try
      {

         PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("E:\\HelloWorld.pdf"));
         writer.setEncryption(USER_PASSWORD.getBytes(),OWNER_PASSWORD.getBytes(), PdfWriter.ALLOW_PRINTING,PdfWriter.ENCRYPTION_AES_128);
         document.open();
         document.add(new Paragraph("This is Password Protected PDF document."));
         document.close();
         writer.close();
      } catch (DocumentException e)
      {
         e.printStackTrace();
      } catch (FileNotFoundException e)
      {
         e.printStackTrace();
      }
}

vous pouvez le faire avec iText PDF java:

quelques exemples:

http://1t3xt.info/examples/browse/?page=example&id = 42

Bibliothèque de FOP permet également le cryptage:

http://xmlgraphics.apache.org/fop/0.94/pdfencryption.html

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top