Leadtools.Pdf Namespace : PDFSecurityOptions Class |
[SerializableAttribute()] public class PDFSecurityOptions
'Declaration <SerializableAttribute()> Public Class PDFSecurityOptions
'Usage Dim instance As PDFSecurityOptions
public sealed class PDFSecurityOptions
function Leadtools.Pdf.PDFSecurityOptions()
[SerializableAttribute()] public ref class PDFSecurityOptions
The PDFSecurityOptions class is used as the type for the SecurityOptions and used to set the security and encryption options to use when creating or updating PDF files.
The following methods of the PDFFile class will use the secutity options set in .SecurityOptions when updating or created a PDF file:
If the value of PDFFile.SecurityOptions is null (Nothing in Visual Basic), then the PDFFile will not encrypt the result PDF file.
There are two different ways to protect a PDF file with a password:
By using a user password set in UserPassword. In this mode, external viewers such as Adobe Acrobat will ask the user for the same password when opening the file for viewing. If the correct password is supplied, then all operations and rights are granted.
By using an owner password set in OwnerPassword. In this mode, external viewers such as Adobe Acrobat will ask the user for the same password when opening the file for viewing. If the correct password is supplied, the editor will check the various access rights properties to allow or disallow certain operations on the PDF file such as printing or editing.
You cannot use both UserPassword and OwnerPassword in the same PDF file. If both values are set, then the PDFFile object will use OwnerPassword and ignore UserPassword.
Public Sub PDFFileSecurityOptionsExample() Dim sourceFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD.pdf") Dim destinationFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_EncryptedNoPrint.pdf") Dim pdfFileObj As New PDFFile(sourceFileName) ' Set the security options pdfFileObj.SecurityOptions = New PDFSecurityOptions() pdfFileObj.SecurityOptions.UserPassword = "LEAD" pdfFileObj.SecurityOptions.PrintEnabled = False pdfFileObj.SecurityOptions.HighQualityPrintEnabled = False pdfFileObj.SecurityOptions.EncryptionMode = PDFEncryptionMode.RC128Bit ' Encrypt the file by saving it to the destination file pdfFileObj.Convert(1, -1, destinationFileName) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void PDFFileSecurityOptionsExample() { string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD.pdf"); string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_EncryptedNoPrint.pdf"); PDFFile pdfFile = new PDFFile(sourceFileName); // Set the security options pdfFile.SecurityOptions = new PDFSecurityOptions(); pdfFile.SecurityOptions.UserPassword = "LEAD"; pdfFile.SecurityOptions.PrintEnabled = false; pdfFile.SecurityOptions.HighQualityPrintEnabled = false; pdfFile.SecurityOptions.EncryptionMode = PDFEncryptionMode.RC128Bit; // Encrypt the file by saving it to the destination file pdfFile.Convert(1, -1, destinationFileName); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2