cete.dynamicpdf.cryptography.aes256security
Aes256Security
- Namespace: ceTe.DynamicPDF.Cryptography
- Assemblies: ceTe.DynamicPDF.40.dll
Represents AES 256 bit PDF document security.
public class Aes256Security : Security
Public Class Aes256Security
Inherits Security
Inheritance: Object → Security → Aes256Security
Licensing
This class is a DynamicPDF Generator Enterprise Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Generator for .NET Enterprise Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF ReportWriter for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Examples
The following example will set AES 256 bit security for the document
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Cryptography
Module MyModule
Sub Main()
' Create a PDF Document
Dim MyDocument As Document = New Document()
' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)
' Create a AES 256 bit security object
Dim security As Aes256Security = New Aes256Security("owner", "user")
' Add the security object to the document
MyDocument.Security = security
' Create and display a label as a reference
Dim text As String = "This document has been encrypted with AES 256 bit encryption."
MyPage.Elements.Add(New Label(text, 50, 50, 400, 100, Font.Helvetica, 18))
' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.Cryptography;
class MyClass
{
static void Main()
{
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add( page );
// Create a AES 256 bit security object
Aes256Security security = new Aes256Security( "owner", "user" );
// Add the security object to the document
document.Security = security;
// Create and display a label as a reference
string text = "This document has been encrypted with AES 256 bit encryption.";
page.Elements.Add( new Label( text, 50, 50, 400, 100, Font.Helvetica, 18 ) );
// Save the PDF
document.Draw( @"C:\MyDocument.pdf" );
}
}
Remarks
AES 256 bit PDF security is compatible with PDF version 1.5 and higher. This class is FIPS compliant when used in applications that targets .NET Framework 3.5 and higher. Setting document’s PDF version to 1.4 or lower will throw an exception during the creation of PDF. Adobe Acrobat Reader version X or higher is needed to open documents encrypted with this class. For more details on AES 256 bit security take a look at the Security topic.
Constructors
Aes256Security()
Initializes a new instance of the Aes256Security class.
public Aes256Security()
Public Sub New ()
Aes256Security(String)
Initializes a new instance of the Aes256Security class.
public Aes256Security(string password)
Public Sub New (password As String)
Parameters
- password: String
The owner password to open the document.
Aes256Security(String, String)
Initializes a new instance of the Aes256Security class.
public Aes256Security(string ownerPassword, string userPassword)
Public Sub New (ownerPassword As String, userPassword As String)
Parameters
- ownerPassword: String
The owner password to open the document.
- userPassword: String
The user password to open the document.
Properties
AllowAccessibility
Gets or sets if accessibility programs should be able to read the documents text and images for the user.
public bool AllowAccessibility { get; set; }
Public Property AllowAccessibility As Boolean
Property Value
AllowCopy
Gets or sets if text and images can be copied to the clipboard by the user. (Inherited from Security)
public bool AllowCopy { get; set; }
Public Property AllowCopy As Boolean
Property Value
AllowDocumentAssembly
Gets or sets if the document can be assembled and manipulated by the user.
public bool AllowDocumentAssembly { get; set; }
Public Property AllowDocumentAssembly As Boolean
Property Value
AllowEdit
Gets or sets if the document can be edited by the user. (Inherited from Security)
public bool AllowEdit { get; set; }
Public Property AllowEdit As Boolean
Property Value
AllowFormFilling
Gets or sets if form filling should be allowed by the user.
public bool AllowFormFilling { get; set; }
Public Property AllowFormFilling As Boolean
Property Value
AllowHighResolutionPrinting
Gets or sets if the document can be printed at a high resolution by the user.
public bool AllowHighResolutionPrinting { get; set; }
Public Property AllowHighResolutionPrinting As Boolean
Property Value
AllowPrint
Gets or sets if the document can be printed by the user. (Inherited from Security)
public bool AllowPrint { get; set; }
Public Property AllowPrint As Boolean
Property Value
AllowUpdateAnnotsAndFields
Gets or sets if annotations and form fields can be added, edited and modified by the user. (Inherited from Security)
public bool AllowUpdateAnnotsAndFields { get; set; }
Public Property AllowUpdateAnnotsAndFields As Boolean
Property Value
DocumentComponents
Gets or sets the documents components to be encrypted.
public EncryptDocumentComponents DocumentComponents { get; set; }
Public Property DocumentComponents As EncryptDocumentComponents
Property Value
Examples
This example shows how to encrypt only file attachments of the document using AES 256 bit encryption.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Cryptography
Module MyModule
Sub Main()
' Create a PDF Document
Dim MyDocument As Document = New Document
' Create a Page and add it to the document
Dim MyPage As Page = New Page
MyDocument.Pages.Add(MyPage)
' Create a AES 256 bit security object
Dim security As Aes256Security = New Aes256Security("password")
' Set DocumentComponents property to OnlyFileAttachments
security.DocumentComponents = EncryptDocumentComponents.OnlyFileAttachments
' Add the security object to the document
MyDocument.Security = security
' Create and display a label as a reference
Dim text As String = "This document has been encrypted with AES 256 bit encryption."
MyPage.Elements.Add(New Label(text, 50, 50, 400, 100, Font.Helvetica, 18))
' Create an instances of EmbeddedFile
Dim embeddedFile As EmbeddedFile = New EmbeddedFile("C:\Document.pdf")
' Add embeddedFile to the EmbeddedFileList of the document class
MyDocument.EmbeddedFiles.Add( embeddedFile )
' Set the PageMode to the ShowAttachments
MyDocument.InitialPageMode = PageMode.ShowAttachments
' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.Cryptography;
class MyClass
{
static void Main()
{
// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add( page );
// Create a AES 256 bit security object
Aes256Security security = new Aes256Security( "password" );
// Set DocumentComponents property to OnlyFileAttachments
security.DocumentComponents = EncryptDocumentComponents.OnlyFileAttachments;
// Add the security object to the document
document.Security = security;
// Create and display a label as a reference
string text = "This document has been encrypted with AES 256 bit encryption.";
page.Elements.Add( new Label( text, 50, 50, 400, 100, Font.Helvetica, 18 ) );
// Create an instance of EmbeddedFile
EmbeddedFile embeddedFile = new EmbeddedFile(@"C:\Document.pdf");
// Add the embeddedFile to the EmbeddedFileList of the document class
document.EmbeddedFiles.Add( embeddedFile );
// Set the PageMode to the ShowAttachments
document.InitialPageMode = PageMode.ShowAttachments;
// Save the PDF
document.Draw( @"C:\MyDocument.pdf" );
}
}
OwnerPassword
Gets or sets the owner password. (Inherited from Security)
public string OwnerPassword { get; set; }
Public Property OwnerPassword As String
Property Value
UserPassword
Gets or sets the user password. (Inherited from Security)
public string UserPassword { get; set; }
Public Property UserPassword As String
Property Value
Methods
Draw(DocumentWriter, Encrypter)
Draws the encrypter dictionary to the given DocumentWriter object.
public void Draw(DocumentWriter writer, Encrypter encrypter)
Sub Draw(writer As DocumentWriter, encrypter As Encrypter)
Parameters
- writer: DocumentWriter
DocumentWriter object to receive the output.
- encrypter: Encrypter
Encrypter object used to encrypt the document.
Equals(Object)
Determines whether the specified Object is equal to the current Object . (Inherited from Object)
public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean
Parameters
- obj: Object
The Object to compare with the current Object .
Returns
true if the specified Object is equal to the current Object ; otherwise, false.
GetEncrypter(Byte[])
Gets a 256 bit Encrypter object to be used for encrypting the document.
public Encrypter GetEncrypter(Byte[] id)
Function GetEncrypter(id As Byte()) As Encrypter
Parameters
- id: Byte[]
ID of the current PDF document.
Returns
An Encrypter .
GetHashCode()
Serves as a hash function for a particular type. (Inherited from Object)
public int GetHashCode()
Function GetHashCode() As Integer
Returns
A hash code for the current Object .
GetType()
Gets the Type of the current instance. (Inherited from Object)
public Type GetType()
Function GetType() As Type
Returns
The Type instance that represents the exact runtime type of the current instance.
ToString()
Returns a String that represents the current Object . (Inherited from Object)
public string ToString()
Function ToString() As String
Returns
A String that represents the current Object .