Beispiel #1
0
        /// <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="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 void Encrypt(PdfReader reader, Stream os, IDictionary <String, String> newInfo)
        {
            WriterProperties writerProperties = new WriterProperties();

            writerProperties.encryptionProperties = properties;
            PdfWriter          writer             = new PdfWriter(os, writerProperties);
            StampingProperties stampingProperties = new StampingProperties();

            stampingProperties.SetEventCountingMetaInfo(metaInfo);
            PdfDocument document = new PdfDocument(reader, writer, stampingProperties);

            document.GetDocumentInfo().SetMoreInfo(newInfo);
            document.Close();
        }
Beispiel #2
0
 /// <summary>Create a PdfWriter writing to the passed filename and using the passed writer properties.</summary>
 /// <param name="filename">filename of the resulting pdf.</param>
 /// <param name="properties">writerproperties to use.</param>
 /// <exception cref="System.IO.FileNotFoundException"/>
 public PdfWriter(String filename, WriterProperties properties)
     : this(FileUtil.GetBufferedOutputStream(filename), properties)
 {
 }