←Select platform

SecurityOptions Property

Summary
PDF security and encryption options to use when updating or creating a PDF file.
Syntax
C#
C++/CLI
Java
Python
public PDFSecurityOptions SecurityOptions { get; set; } 
public PDFSecurityOptions getSecurityOptions(); 
public void setSecurityOptions( 
   PDFSecurityOptions pDFSecurityOptions 
); 
public: 
property PDFSecurityOptions^ SecurityOptions { 
   PDFSecurityOptions^ get(); 
   void set (    PDFSecurityOptions^ ); 
} 
SecurityOptions # get and set (PDFFile) 

Property Value

A PDFSecurityOptions that contain the PDF security and encryption options to use when this PDFFile is used to update or create a PDF file. Default value is null.

Remarks

The following methods of the PDFFile class will use the security options set in SecurityOptions when updating or creating a PDF file:

If the value of SecurityOptions is null, then the PDFFile will not encrypt the resulting 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.

Similar to the DocumentProperties property, the value of SecurityOptions will not be modified when a PDF file is loaded in this object using the Load method.

To determine whether a PDF file is encrypted and requires a password to view or modify, use the IsEncrypted method.

Example
C#
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"; 
} 
Requirements

Target Platforms

See Also

Reference

PDFFile Class

PDFFile Members

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.