cete.dynamicpdf.cryptography.aes128security
Aes128Security
- Namespace: ceTe.DynamicPDF.Cryptography
- Assemblies: DynamicPDF.CoreSuite.dll
Represents AES 128 bit PDF document security.
public class Aes128Security : Security
Public Class Aes128Security
Inherits Security
Inheritance: Object → Security → Aes128Security
Licensing Info
This class is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Examples
The following example will set the AES security of the document so that the anyone who logs in with the user password will not be able to edit annotations or form fields.
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 128 bit security object
Dim security As Aes128Security = New Aes128Security("owner", "user")
' Set these properties to make form fields read only
security.AllowFormFilling = False
security.AllowEdit = False
security.AllowUpdateAnnotsAndFields = False
' 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 128 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;
public class Example
{
public static void CreatePDF(string outputPath)
{
// 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 128 bit security object
Aes128Security security = new Aes128Security( "owner", "user" );
// Set these properties to make form fields read only
security.AllowFormFilling = false;
security.AllowEdit = false;
security.AllowUpdateAnnotsAndFields = false;
// 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 128 bit encryption.";
page.Elements.Add( new Label( text, 50, 50, 400, 100, Font.Helvetica, 18 ) );
// Save the PDF
document.Draw( outputPath );
}
}
Remarks
AES 128 bit PDF security is compatible with PDF version 1.5 and higher and can be read with Adobe Acrobat Reader version 7 or higher. Older readers will not be able to read document encrypted with this security. Setting document version to lower values will throw an exception at the time of draw. For more details on AES 128 bit security take a look at the Security topic.
Constructors
Aes128Security()
Initializes a new instance of the Aes128Security class.
public Aes128Security()
Public Sub New ()
Licensing Info
This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Aes128Security(String)
Initializes a new instance of the Aes128Security class.
public Aes128Security(string password)
Public Sub New (password As String)
Parameters
- password: String
The owner password to open the document.
Licensing Info
This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Aes128Security(String, String)
Initializes a new instance of the Aes128Security class.
public Aes128Security(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.
Licensing Info
This constructor is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
DocumentComponents
Gets or sets the documents components to be encrypted.
public EncryptDocumentComponents DocumentComponents { get; set; }
Public Property DocumentComponents As EncryptDocumentComponents
Property Value
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
Examples
This example shows how to encrypt a document using AES 128 bit encryption excluding metadata.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements
Imports ceTe.DynamicPDF.Cryptography
Imports ceTe.DynamicPDF.Xmp
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 128 bit security object
Dim security As Aes128Security = New Aes128Security("owner", "user")
' Set DocumentComponents property to AllExceptMetadata
security.DocumentComponents = EncryptDocumentComponents.AllExceptMetadata
' 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 128 bit encryption."
MyPage.Elements.Add(New Label(text, 50, 50, 400, 100, Font.Helvetica, 18))
' Create an Xmp Metadata
Dim MyXmp As XmpMetadata = New XmpMetadata
' Dublin Core Schema.
Dim Mydc As DublinCoreSchema = MyXmp.DublinCore
Mydc.Contributors.Add( "Abc" )
Mydc.Contributors.Add( "Xyz" )
Mydc.Contributors.Add( "Pqrs" )
Mydc.Coverage = "To test all the attributes of schema's provided"
Mydc.Creators.Add( "MyProduct" )
Mydc.Creators.Add( "MyCompany" )
Mydc.Date.Add( DateTime.Now )
Mydc.Description.AddLang( "en-us", "XMP Schema's test" )
Mydc.Identifier = "First XMP pdf"
Mydc.Publisher.Add( "mydomain.com" )
Mydc.Publisher.Add( "My Company" )
Mydc.Relation.Add( "test pdf with xmp" )
Mydc.Rights.DefaultText = "US English"
Mydc.Rights.AddLang( "en-us", "All rights reserved 2012, MyCompany." )
Mydc.Source = "XMP Project"
Mydc.Subject.Add( "eXtensible Metadata Platform" )
Mydc.Title.AddLang( "en-us", "XMP" )
Mydc.Title.AddLang( "it-it", "XMP - Piattaforma Estendible di Metadata" )
Mydc.Title.AddLang( "du-du", "De hallo Wereld" )
Mydc.Title.AddLang( "fr-fr", "XMP - Une Platforme Extensible pour les M�t�donn�es" )
Mydc.Title.AddLang( "DE-DE", "���� Hallo Welt" )
Mydc.Type.Add( "Pdf file containing xmp metadata" )
' Basic Schema.
Dim Mybs As BasicSchema = MyXmp.BasicSchema
Mybs.Advisory.Add( "Date" )
Mybs.Advisory.Add( "Contributors" )
Mybs.Nickname = "xyz"
' Rights Management Schema.
Dim Myrm As RightsManagementSchema = New RightsManagementSchema
Myrm.Marked2 = CopyrightStatus.PublicDomain
Myrm.Owner.Add( "MyCompany" )
Myrm.UsageTerms.AddLang( "en-us", "Contact MyCompany" )
MyXmp.AddSchema(Myrm)
' Basic Job Ticket Schema.
Dim MyJob As BasicJobTicketSchema = New BasicJobTicketSchema
MyJob.JobRef.Add( "MyCompany", "Xmp Test", new Uri( "http://www.mydomain.com/" ) )
MyJob.JobRef.Add( "MyCompany", "XMP Metadata", new Uri( "http://www.mydomain.com/" ) )
MyXmp.AddSchema(MyJob)
' Paged-Text Schema.
Dim Mypt As PagedTextSchema = New PagedTextSchema
MyXmp.AddSchema(Mypt)
' Add the Xmp Metadata to the document
MyDocument.XmpMetadata = MyXmp
' 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;
using ceTe.DynamicPDF.Xmp;
public class Example
{
public static void CreatePDF(string outputPath)
{
// 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 128 bit security object
Aes128Security security = new Aes128Security( "owner", "user" );
// Set DocumentComponents property to AllExceptMetadata
security.DocumentComponents = EncryptDocumentComponents.AllExceptMetadata;
// 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 128 bit encryption.";
page.Elements.Add( new Label( text, 50, 50, 400, 100, Font.Helvetica, 18 ) );
// Create an Xmp Metadata
XmpMetadata xmp = new XmpMetadata();
// Dublin Core Schema.
DublinCoreSchema dc = xmp.DublinCore;
dc.Contributors.Add( "Abc" );
dc.Contributors.Add( "Xyz" );
dc.Contributors.Add( "Pqrs" );
dc.Coverage = "To test all the attributes of schema's provided";
dc.Creators.Add( "MyProduct" );
dc.Creators.Add( "MyCompany" );
dc.Date.Add( DateTime.Now );
dc.Description.AddLang( "en-us", "XMP Schema's test" );
dc.Identifier = "First XMP pdf";
dc.Publisher.Add( "mydomain.com" );
dc.Publisher.Add( "MyCompany" );
dc.Relation.Add( "test pdf with xmp" );
dc.Rights.DefaultText = "US English";
dc.Rights.AddLang( "en-us", "All rights reserved 2012, MyCompany." );
dc.Source = "XMP Project";
dc.Subject.Add( "eXtensible Metadata Platform" );
dc.Title.AddLang( "en-us", "XMP" );
dc.Title.AddLang( "it-it", "XMP - Piattaforma Estendible di Metadata" );
dc.Title.AddLang( "du-du", "De hallo Wereld" );
dc.Title.AddLang( "fr-fr", "XMP - Une Platforme Extensible pour les M�t�donn�es" );
dc.Title.AddLang( "DE-DE", "���� Hallo Welt" );
dc.Type.Add( "Pdf file containing xmp metadata" );
// Basic Schema.
BasicSchema bs = xmp.BasicSchema;
bs.Advisory.Add( "Date" );
bs.Advisory.Add( "Contributors" );
bs.Nickname = "xyz";
// Rights Management Schema.
RightsManagementSchema rm = new RightsManagementSchema();
rm.Marked2 = CopyrightStatus.PublicDomain;
rm.Owner.Add( "MyCompany" );
rm.UsageTerms.AddLang( "en-us", "Contact MyCompany" );
xmp.AddSchema( rm );
// Basic Job Ticket Schema.
BasicJobTicketSchema job = new BasicJobTicketSchema();
job.JobRef.Add( "MyCompany", "Xmp Test", new Uri( "http://www.mydomain.com/" ) );
job.JobRef.Add( "MyCompany", "XMP Metadata", new Uri( "http://www.mydomain.com/" ) );
xmp.AddSchema( job );
// Paged-Text Schema.
PagedTextSchema pt = new PagedTextSchema();
xmp.AddSchema(pt);
// Add the Xmp Metadata to the document
document.XmpMetadata = xmp;
// Save the PDF
document.Draw( outputPath );
}
}
OwnerPassword
Gets or sets the owner password. (Inherited from Security)
public string OwnerPassword { get; set; }
Public Property OwnerPassword As String
Property Value
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
UserPassword
Gets or sets the user password. (Inherited from Security)
public string UserPassword { get; set; }
Public Property UserPassword As String
Property Value
Licensing Info
This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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.
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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.
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
GetEncrypter(Byte[])
Gets a 128 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 .
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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 .
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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.
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.
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 .
Licensing Info
This method is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:
- An active DynamicPDF Ultimate Subscription
- An active DynamicPDF Professional or Professional Plus Subscription with DynamicPDF Core Suite selected.
- A DynamicPDF Core Suite for .NET v12.X Developer License.