We recently released an update that introduces AES-256 bit and AES-128 bit encryption to our .NET PDF creation and merging library. We have offered encryption since 2002, but this was limited to RC4-40 bit and RC4-128 bit security until this release. We have also restructured the API a bit in order to easily accommodate new encryption methods in the future.
Encryption is now handled by 4 classes in a new ceTe.DynamicPDF.Cryptography namespace:
All security classes allow restrictions to be placed on a PDF to restrict printing, modification, copying content or updating/adding text annotations or form fields. The 128-bit and higher classes allow restrictions to be placed on a PDF to restrict filling in existing form fields, extracting text and graphics for accessibility purposes, modifying the pages included, high resolution printing or leaving the XMP metadata unencrypted. The AES classes also add the ability to encrypt only file attachments.
The C# code to add AES-256 bit encryption to a new document is very straight forward:
Document document = new Document();
Page page = new Page();
page.Elements.Add(new Label("AES-256 bit encrypted PDF.", 0, 0, 500, 15));
document.Pages.Add(page);
// Add the encryption
Aes256Security security = new Aes256Security("ownerpassword", "userpassword");
security.AllowHighResolutionPrinting = false;
// Set other encryption options
document.Security = security;
// Output the PDF
document.Draw("MyPDF.pdf");
The C# code to add AES-256 bit encryption to an existing PDF is shown below:
MergeDocument document = new MergeDocument("MyInputPDF.pdf");
// Add the encryption
Aes256Security security = new Aes256Security("ownerpassword", "userpassword");
security.AllowHighResolutionPrinting = false;
// Set other encryption options
document.Security = security;
// Output the PDF
document.Draw("MyPDF.pdf");
Keep in mind that AES-256 bit encryption is only supported by Acrobat 9 and above and AES-128 bit encryption by Acrobat 7 and above. Additional information about the security and encryption features can be found in our Help Library at the link below:
Are there any new security or encryption features that you would like to see in our DynamicPDF libraries? Let me know by commenting below.