Encryptor Example : Encrypted PDF « PDF RTF « Java






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)

Related examples in the same category

1.Encrypted PDF: Allow Assembly, FillIn, ScreenReaders, ModifyContents
2.Encrypted PDF: AllowCopy, PrintingEncrypted PDF: AllowCopy, Printing
3.Encrypted PDF with: User Password and Owner PasswordEncrypted PDF with: User Password and Owner Password