Encryptor Example
import java.io.FileOutputStream; import com.lowagie.text.pdf.PdfEncryptor; import com.lowagie.text.pdf.PdfReader; import com.lowagie.text.pdf.PdfWriter; public class EncryptorExamplePDF { public static void main(String[] args) { try { PdfReader reader = new PdfReader("YourOwnPDF.pdf"); PdfEncryptor.encrypt(reader, new FileOutputStream("EncryptorExamplePDF.pdf"), "Hello".getBytes(), "World".getBytes(), PdfWriter.AllowPrinting | PdfWriter.AllowCopy, false); } catch (Exception e) { e.printStackTrace(); } } }
1. | Encrypted PDF: Allow Assembly, FillIn, ScreenReaders, ModifyContents | ![]() | |
2. | Encrypted PDF: AllowCopy, Printing | ![]() | |
3. | Encrypted PDF with: User Password and Owner Password | ![]() |