Mega Code Archive

 
Categories / Java / PDF RTF
 

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();     }   } }                     itext.zip( 1,748 k)