PdfEncryptionAlgorithm Enumeration |
Specifies the encryption algorithm to use for encrypting a PDF document.
Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2025.2.13
Syntaxpublic enum PdfEncryptionAlgorithm
Public Enumeration PdfEncryptionAlgorithm
MembersMember name | Value | Description |
---|
RC4_40 | 0 |
RC4 encryption, key length of 40 bits.
|
RC4_128 | 1 |
RC4 encryption, key length of 128 bits.
|
ExampleSee Developer Guide: Create and secure a PDF document by password
Secure a Document by password using C#
using System;
using SautinSoft.Document;
using SautinSoft.Document.Drawing;
using System.IO;
using System.Linq;
namespace Example
{
class Program
{
static void Main(string[] args)
{
SecureDocument();
}
public static void SecureDocument()
{
string filePath = @"ProtectedDocument.pdf";
DocumentCore dc = new DocumentCore();
dc.Content.End.Insert("Hello World!!!", new CharacterFormat() { FontName = "Verdana", Size = 65.5f, FontColor = Color.Orange });
PdfSaveOptions so = new PdfSaveOptions();
so.EncryptionDetails.UserPassword = "12345";
so.EncryptionDetails.EncryptionAlgorithm = PdfEncryptionAlgorithm.RC4_128;
so.EncryptionDetails.Permissions = PdfPermissions.Printing;
dc.Save(filePath, so);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
}
}
}
Secure a Document by password using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Module Sample
Sub Main()
SecureDocument()
End Sub
Sub SecureDocument()
Dim filePath As String = "ProtectedDocument.pdf"
Dim dc As New DocumentCore()
dc.Content.End.Insert("Hello World!!!", New CharacterFormat() With {
.FontName = "Verdana",
.Size = 65.5F,
.FontColor = Color.Orange
})
Dim so As New PdfSaveOptions()
so.EncryptionDetails.UserPassword = "12345"
so.EncryptionDetails.EncryptionAlgorithm = PdfEncryptionAlgorithm.RC4_128
so.EncryptionDetails.Permissions = PdfPermissions.Printing
dc.Save(filePath, so)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
End Sub
End Module
See Also