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

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

Introduction

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

Prototype

int ALLOW_MODIFY_CONTENTS

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

Click Source Link

Document

The operation permitted when the document is opened with the user password

Usage

From source file:org.alfresco.extension.pdftoolkit.repo.action.executer.PDFEncryptionActionExecuter.java

License:Apache License

/**
 * Build the permissions mask for iText//from ww w.ja  va2 s . c  om
 * 
 * @param options
 * @return
 */
private int buildPermissionMask(Map<String, Object> options) {
    int permissions = 0;

    if ((Boolean) options.get(PARAM_ALLOW_PRINT)) {
        permissions = permissions | PdfWriter.ALLOW_PRINTING;
    }
    if ((Boolean) options.get(PARAM_ALLOW_COPY)) {
        permissions = permissions | PdfWriter.ALLOW_COPY;
    }
    if ((Boolean) options.get(PARAM_ALLOW_CONTENT_MODIFICATION)) {
        permissions = permissions | PdfWriter.ALLOW_MODIFY_CONTENTS;
    }
    if ((Boolean) options.get(PARAM_ALLOW_ANNOTATION_MODIFICATION)) {
        permissions = permissions | PdfWriter.ALLOW_MODIFY_ANNOTATIONS;
    }
    if ((Boolean) options.get(PARAM_ALLOW_SCREEN_READER)) {
        permissions = permissions | PdfWriter.ALLOW_SCREENREADERS;
    }
    if ((Boolean) options.get(PARAM_ALLOW_DEGRADED_PRINT)) {
        permissions = permissions | PdfWriter.ALLOW_DEGRADED_PRINTING;
    }
    if ((Boolean) options.get(PARAM_ALLOW_ASSEMBLY)) {
        permissions = permissions | PdfWriter.ALLOW_ASSEMBLY;
    }
    if ((Boolean) options.get(PARAM_ALLOW_FORM_FILL)) {
        permissions = permissions | PdfWriter.ALLOW_FILL_IN;
    }

    return permissions;
}

From source file:org.la3.pdfunlock.PdfUnlock.java

License:BSD License

private void launch(String[] args) throws Exception {
    parseOptions(args);//w  w w  .  j  a v a  2s .c om

    System.err.println("Unlocking " + lockedFile + " to " + unlockedFile);

    PdfReader reader;
    if (password == null) {
        reader = new PdfReader(lockedFile);
    } else {
        reader = new PdfReader(lockedFile, password.getBytes());
    }
    PdfEncryptor.encrypt(reader, new FileOutputStream(unlockedFile), null, null,
            PdfWriter.ALLOW_ASSEMBLY | PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_DEGRADED_PRINTING
                    | PdfWriter.ALLOW_FILL_IN | PdfWriter.ALLOW_MODIFY_ANNOTATIONS
                    | PdfWriter.ALLOW_MODIFY_CONTENTS | PdfWriter.ALLOW_PRINTING
                    | PdfWriter.ALLOW_SCREENREADERS,
            false);

    System.err.println("PDF Unlocked successfully!");
    System.exit(0);
}