Class PdfEncryptionOptions
Specifies the encryption option.
Inheritance
System.Object
PdfEncryptionOptions
Namespace: Syncfusion.Pdf.Security
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public sealed class PdfEncryptionOptions : Enum
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
EncryptAllContents
To encrypt all the document contents.
Declaration
public const PdfEncryptionOptions EncryptAllContents
Field Value
Type |
---|
PdfEncryptionOptions |
EncryptAllContentsExceptMetadata
To encrypt all the document contents except metadata.
Declaration
public const PdfEncryptionOptions EncryptAllContentsExceptMetadata
Field Value
Type |
---|
PdfEncryptionOptions |
EncryptOnlyAttachments
To encrypt atttachment files only.
Declaration
public const PdfEncryptionOptions EncryptOnlyAttachments
Field Value
Type |
---|
PdfEncryptionOptions |