Enum PdfEncryptionOptions
Specifies the encryption option.
Namespace: Syncfusion.Pdf.Security
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public enum PdfEncryptionOptions
Examples
PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();
PdfGraphics graphics = page.Graphics;
PdfStandardFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, 20f, PdfFontStyle.Bold);
PdfBrush brush = PdfBrushes.Black;
PdfSecurity security = document.Security;
security.KeySize = PdfEncryptionKeySize.Key128Bit;
security.Algorithm = PdfEncryptionAlgorithm.AES;
security.EncryptionOptions = PdfEncryptionOptions.EncryptAllContents
security.UserPassword = "password";
graphics.DrawString("Encrypted with AES 128bit", font, brush, new PointF(0, 40));
PdfAttachment attachment = new PdfAttachment(@"D:\Hello world.docx");
attachment.ModificationDate = DateTime.Now;
attachment.Description = "Hello world.docx";
attachment.MimeType = "application/txt";
document.Attachments.Add(attachment);
document.Save(@"D:\NormalAttach.pdf");
document.Close(true);
Fields
Name | Description |
---|---|
EncryptAllContents | To encrypt all the document contents. |
EncryptAllContentsExceptMetadata | To encrypt all the document contents except metadata. |
EncryptOnlyAttachments | To encrypt atttachment files only. |