Beispiel #1
0
        public void SetOptions(PdfRendererOptions options)
        {
            // Configure the /Info dictionary.
            info = new PdfInfo(doc.NextObjectId());
            if (options.Title != null)
            {
                info.Title = new PdfString(options.Title);
            }
            if (options.Author != null)
            {
                info.Author = new PdfString(options.Author);
            }
            if (options.Subject != null)
            {
                info.Subject = new PdfString(options.Subject);
            }
            if (options.Keywords != String.Empty)
            {
                info.Keywords = new PdfString(options.Keywords);
            }
            if (options.Creator != null)
            {
                info.Creator = new PdfString(options.Creator);
            }
            if (options.Producer != null)
            {
                info.Producer = new PdfString(options.Producer);
            }
            info.CreationDate = new PdfString(PdfDate.Format(DateTime.Now));
            this.objects.Add(info);

            // Configure the security options.
            if (options.UserPassword != null ||
                options.OwnerPassword != null ||
                options.HasPermissions)
            {
                SecurityOptions securityOptions = new SecurityOptions();
                securityOptions.UserPassword = options.UserPassword;
                securityOptions.OwnerPassword = options.OwnerPassword;
                securityOptions.EnableAdding(options.EnableAdd);
                securityOptions.EnableChanging(options.EnableModify);
                securityOptions.EnableCopying(options.EnableCopy);
                securityOptions.EnablePrinting(options.EnablePrinting);

                doc.SecurityOptions = securityOptions;
                encrypt = doc.Writer.SecurityManager.GetEncrypt(doc.NextObjectId());
                this.objects.Add(encrypt);
            }

        }