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

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

Introduction

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

Prototype

@Deprecated
public void setEncryption(final int encryptionType, final String userPassword, final String ownerPassword,
        final int permissions) throws DocumentException 

Source Link

Document

Sets the encryption options for this document.

Usage

From source file:com.github.albfernandez.joinpdf.JoinPdf.java

License:Open Source License

private void setParametersAndHeaders(final PdfWriter writer, final Document document) throws DocumentException {
    if (this.extraCompression) {
        writer.setFullCompression();/*from ww w  .  ja  v  a2 s.  c o m*/
    }
    if (this.isCrypt() && bouncyCastleLoaded) {
        int permisos = PdfWriter.ALLOW_PRINTING;
        writer.setEncryption(null, null, permisos, PdfWriter.ENCRYPTION_AES_128);
    }
    if (!StringUtils.isBlank(this.getMetadataAuthor())) {
        document.addAuthor(this.getMetadataAuthor());
    }
    if (!StringUtils.isBlank(this.getMetadataKeywords())) {
        document.addKeywords(this.getMetadataKeywords());
    }
    if (!StringUtils.isBlank(this.getMetadataTitle())) {
        document.addTitle(this.getMetadataTitle());
    }
    if (!StringUtils.isBlank(this.getMetadataSubject())) {
        document.addSubject(this.getMetadataSubject());
    }
}