List of usage examples for com.itextpdf.text.pdf PdfEncryptor encrypt
public static void encrypt(PdfReader reader, OutputStream os, int type, String userPassword, String ownerPassword, int permissions) throws DocumentException, IOException
From source file:org.la3.pdfunlock.PdfUnlock.java
License:BSD License
private void launch(String[] args) throws Exception { parseOptions(args);//from ww w.j av a 2 s . 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); }