Aes128Security.DocumentComponents Property

Gets or sets the documents components to be encrypted.

public EncryptDocumentComponents DocumentComponents { get; set; }
Public Property DocumentComponents As EncryptDocumentComponents

Property Value

EncryptDocumentComponents

Licensing Info

This property is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

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 );
    }
}

See Also

Aes128Security
ceTe.DynamicPDF.Cryptography

In this topic