5

I have found that using java class we can protect pdf file with password

private static String USER_PASS = "Hello123";

    private static String OWNER_PASS = "Owner123";


    public static void main(String[] args) {
        try {

            OutputStream file = new FileOutputStream(new File("D:\\Test.pdf"));

            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, file);

            writer.setEncryption(USER_PASS.getBytes(), OWNER_PASS.getBytes(),
                    PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128);

            document.open();
            document.add(new Paragraph("Hello World, iText"));
            document.add(new Paragraph(new Date().toString()));

            document.close();
            file.close();

        } catch (Exception e) {

            e.printStackTrace();
        }
    }

But how we can protect pdf file using javascript. I had referred the community question using javascript to password protect pdf but I am not able to solve my problem. Is there any source code so it can help me more. Please help.

Community
  • 1
  • 1
Vikash Patel
  • 1,328
  • 9
  • 28
  • 1
    Possible duplicate of [using javascript to password protect pdf](http://stackoverflow.com/questions/9476184/using-javascript-to-password-protect-pdf) – Samvel Petrosov May 02 '17 at 04:42
  • 1
    thanks for comment .yes but I have found no any source code for making pdf with password protected. – Vikash Patel May 02 '17 at 04:47

0 Answers0