Example usage for com.itextpdf.text.pdf PdfWriter ENCRYPTION_AES_256

List of usage examples for com.itextpdf.text.pdf PdfWriter ENCRYPTION_AES_256

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfWriter ENCRYPTION_AES_256.

Prototype

int ENCRYPTION_AES_256

To view the source code for com.itextpdf.text.pdf PdfWriter ENCRYPTION_AES_256.

Click Source Link

Document

Type of encryption

Usage

From source file:tutorials.encryptpdf.encryptpdf.java

public static void main(String[] args) {
    try {//ww w  .  j  av  a2  s  .c  om
        PdfReader reader = new PdfReader("test.pdf");
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("encrypted.pdf"));
        stamper.setEncryption(null, null, PdfWriter.ALLOW_PRINTING,
                PdfWriter.ENCRYPTION_AES_256 | PdfWriter.DO_NOT_ENCRYPT_METADATA);
        stamper.close();
        reader.close();
    } catch (IOException | DocumentException ex) {
        ex.printStackTrace();
    }
}