Enum PdfEncryptionOptions
- Namespace
- Syncfusion.Pdf.Security
- Assembly
- Syncfusion.Pdf.Portable.dll
Specifies the encryption option.
public enum PdfEncryptionOptions
Fields
EncryptAllContents = 0
To encrypt all the document contents.
EncryptAllContentsExceptMetadata = 1
To encrypt all the document contents except metadata.
EncryptOnlyAttachments = 2
To encrypt atttachment files only.
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);