當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfStamper.SetEncryption方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfStamper.SetEncryption方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfStamper.SetEncryption方法的具體用法?C# PdfStamper.SetEncryption怎麽用?C# PdfStamper.SetEncryption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfStamper的用法示例。


在下文中一共展示了PdfStamper.SetEncryption方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Encrypt

 public void Encrypt(PdfStamper stamper)
 {
     int permission = 0;
     foreach (int i in this.Permissions)
     {
         permission |= (int) i;
     }
     stamper.SetEncryption(this.Encryption, this.UserPwd, this.OwnerPwd, permission);
 }
開發者ID:modulexcite,項目名稱:EasyPdfSigning,代碼行數:9,代碼來源:PDFEncryption.cs

示例2: EncryptPdf

// ---------------------------------------------------------------------------
    /**
     * Manipulates a PDF file src with the file dest as result
     * @param src the original PDF
     */
    public byte[] EncryptPdf(byte[] src) {
      PdfReader reader = new PdfReader(src);
      using (MemoryStream ms = new MemoryStream()) {
        using (PdfStamper stamper = new PdfStamper(reader, ms)) {
          stamper.SetEncryption(
            USER, OWNER, 
            PdfWriter.ALLOW_PRINTING, 
            PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA
          );
        }
        return ms.ToArray();
      }
    }    
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:18,代碼來源:EncryptionPdf.cs

示例3: Encrypt

 /** Entry point to encrypt a PDF document. The encryption parameters are the same as in
  * <code>PdfWriter</code>. The userPassword and the
  *  ownerPassword can be null or have zero length. In this case the ownerPassword
  *  is replaced by a random string. The open permissions for the document can be
  *  AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
  *  AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
  *  The permissions can be combined by ORing them.
  * @param reader the read PDF
  * @param os the output destination
  * @param userPassword the user password. Can be null or empty
  * @param ownerPassword the owner password. Can be null or empty
  * @param permissions the user permissions
  * @param strength128Bits <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length
  * @param newInfo an optional <CODE>String</CODE> map to add or change
  * the info dictionary. Entries with <CODE>null</CODE>
  * values delete the key in the original info dictionary
  * @throws DocumentException on error
  * @throws IOException on error
  */
 public static void Encrypt(PdfReader reader, Stream os, byte[] userPassword, byte[] ownerPassword, int permissions, bool strength128Bits, Dictionary<string,string> newInfo) {
     PdfStamper stamper = new PdfStamper(reader, os);
     stamper.SetEncryption(userPassword, ownerPassword, permissions, strength128Bits);
     stamper.MoreInfo = newInfo;
     stamper.Close();
 }
開發者ID:,項目名稱:,代碼行數:25,代碼來源:

示例4: Encrypt

 /** Entry point to encrypt a PDF document. The encryption parameters are the same as in
  * <code>PdfWriter</code>. The userPassword and the
  *  ownerPassword can be null or have zero length. In this case the ownerPassword
  *  is replaced by a random string. The open permissions for the document can be
  *  AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
  *  AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
  *  The permissions can be combined by ORing them.
  * @param reader the read PDF
  * @param os the output destination
  * @param strength <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length
  * @param userPassword the user password. Can be null or empty
  * @param ownerPassword the owner password. Can be null or empty
  * @param permissions the user permissions
  * @param newInfo an optional <CODE>String</CODE> map to add or change
  * the info dictionary. Entries with <CODE>null</CODE>
  * values delete the key in the original info dictionary
  * @throws DocumentException on error
  * @throws IOException on error
  */
 public static void Encrypt(PdfReader reader, Stream os, bool strength, String userPassword, String ownerPassword, int permissions, Hashtable newInfo) {
     PdfStamper stamper = new PdfStamper(reader, os);
     stamper.SetEncryption(strength, userPassword, ownerPassword, permissions);
     stamper.MoreInfo = newInfo;
     stamper.Close();
 }
開發者ID:pusp,項目名稱:o2platform,代碼行數:25,代碼來源:PdfEncryptor.cs


注:本文中的iTextSharp.text.pdf.PdfStamper.SetEncryption方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。