←Select platform

PDFSecurityOptions Class


PDF security and encryption options.


public class PDFSecurityOptions 
public class PDFSecurityOptions 
public ref class PDFSecurityOptions  
class PDFSecurityOptions: 


The PDFSecurityOptions class is used as the type for the SecurityOptions and used to read and write the security and encryption options to use with PDF files.

When reading PDF documents, PDFDocument.SecurityOptions will always be populated automatically when the PDFDocument object is initialized.

When writing PDF documents, the following methods of the PDFFile class will use the security options set in PDFFile.SecurityOptions when updating or created a PDF file:

If the value of PDFFile.SecurityOptions is null, then the PDFFile will not encrypt the result PDF file.

User Password and Owner Password

There are two different types of passwords to protect different aspects of a PDF file with a password:


using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
/// This example will encrypt a PDF file with both a user password and an owner password and restrict printing. 
public void PDFFileSecurityOptionsExample() 
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.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.OwnerPassword = "LEAD_SECRET"; 
   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:\LEADTOOLS22\Resources\Images"; 


Target Platforms

See Also

PDFSecurityOptions Members

Leadtools.Pdf Namespace

Help Version 22.0.2023.7.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.