public PdfWriter(Stream os, WriterProperties properties) : base(FileUtil.WrapWithBufferedOutputStream(os)) { // For internal usage only //forewarned is forearmed this.properties = properties; EncryptionProperties encryptProps = properties.encryptionProperties; if (properties.IsStandardEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.userPassword, encryptProps.ownerPassword, encryptProps.standardEncryptPermissions , encryptProps.encryptionAlgorithm, PdfEncryption.GenerateNewDocumentId()); } else { if (properties.IsPublicKeyEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.publicCertificates, encryptProps.publicKeyEncryptPermissions, encryptProps .encryptionAlgorithm); } } if (properties.debugMode) { SetDebugMode(); } }
public WriterProperties() { smartMode = false; debugMode = false; compressionLevel = CompressionConstants.DEFAULT_COMPRESSION; isFullCompression = null; encryptionProperties = new EncryptionProperties(); }
/// <summary>Entry point to encrypt a PDF document.</summary> /// <param name="reader">the read PDF</param> /// <param name="os">the output destination</param> /// <param name="properties"> /// encryption properties. See /// <see cref="EncryptionProperties"/> /// . /// </param> /// <param name="newInfo"> /// an optional /// <c>String</c> /// map to add or change /// the info dictionary. Entries with /// <see langword="null"/> /// values delete the key in the original info dictionary /// </param> public static void Encrypt(PdfReader reader, Stream os, EncryptionProperties properties, IDictionary <String , String> newInfo) { WriterProperties writerProperties = new WriterProperties(); writerProperties.encryptionProperties = properties; PdfWriter writer = new PdfWriter(os, writerProperties); PdfDocument document = new PdfDocument(reader, writer); document.GetDocumentInfo().SetMoreInfo(newInfo); document.Close(); }
protected internal virtual void InitCryptoIfSpecified(PdfVersion version) { EncryptionProperties encryptProps = properties.encryptionProperties; if (properties.IsStandardEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.userPassword, encryptProps.ownerPassword, encryptProps.standardEncryptPermissions , encryptProps.encryptionAlgorithm, PdfEncryption.GenerateNewDocumentId(), version); } else { if (properties.IsPublicKeyEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.publicCertificates, encryptProps.publicKeyEncryptPermissions, encryptProps .encryptionAlgorithm, version); } } }
protected internal virtual void InitCryptoIfSpecified(PdfVersion version) { EncryptionProperties encryptProps = properties.encryptionProperties; if (properties.IsStandardEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.userPassword, encryptProps.ownerPassword, encryptProps.standardEncryptPermissions , encryptProps.encryptionAlgorithm, ByteUtils.GetIsoBytes(this.document.GetOriginalDocumentId().GetValue ()), version); } else { if (properties.IsPublicKeyEncryptionUsed()) { crypto = new PdfEncryption(encryptProps.publicCertificates, encryptProps.publicKeyEncryptPermissions, encryptProps .encryptionAlgorithm, version); } } }
/// <summary>Entry point to encrypt a PDF document.</summary> /// <param name="reader">the read PDF</param> /// <param name="os">the output destination</param> /// <param name="properties"> /// encryption properties. See /// <see cref="EncryptionProperties"/> /// . /// </param> public static void Encrypt(PdfReader reader, Stream os, EncryptionProperties properties) { Encrypt(reader, os, properties, null); }
/// <summary>Entry point to encrypt a PDF document.</summary> /// <param name="reader">the read PDF</param> /// <param name="os">the output destination</param> /// <param name="properties"> /// encryption properties. See /// <see cref="EncryptionProperties"/> /// . /// </param> /// <param name="newInfo"> /// an optional /// <c>String</c> /// map to add or change /// the info dictionary. Entries with /// <see langword="null"/> /// values delete the key in the original info dictionary /// </param> public static void Encrypt(PdfReader reader, Stream os, EncryptionProperties properties, IDictionary <String , String> newInfo) { new iText.Kernel.Pdf.PdfEncryptor().SetEncryptionProperties(properties).Encrypt(reader, os, newInfo); }
/// <summary> /// Sets the /// <see cref="EncryptionProperties"/> /// </summary> /// <param name="properties">the properties to set</param> /// <returns> /// this /// <see cref="PdfEncryptor"/> /// instance /// </returns> public iText.Kernel.Pdf.PdfEncryptor SetEncryptionProperties(EncryptionProperties properties) { this.properties = properties; return(this); }