Aes256Security.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 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;

public class Example
{
    public static void CreatePDF(string inputFilePath, 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 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(inputFilePath);
	
        // 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( outputPath );
    }
}

See Also

Aes256Security
ceTe.DynamicPDF.Cryptography

In this topic