16 Mart 2011 Çarşamba

ITextSharp Encrypt-Decrypt PDF

Encrypt PDF

using iTextSharp.text.pdf;

public void encryptPdf(String source, String destination,byte[] User,byte[] Owner)
  {
      PdfReader reader = new PdfReader(source);
      PdfStamper stamper = new PdfStamper(reader, new FileStream(destination,FileMode.Create));
      stamper.SetEncryption(User, Owner, PdfWriter.ALLOW_PRINTING,     PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA);
       stamper.Close();
  }

Decrypt PDF

using iTextSharp.text.pdf;

public void decryptPdf(string source, string destination,byte[] Owner)
  {
      PdfReader reader = new PdfReader(source, Owner);
      PdfStamper stamper = new PdfStamper(reader, new FileStream(destination, FileMode.Create));
      stamper.Close();
  }

Hiç yorum yok:

Yorum Gönder