←Select platform

Password Property

Summary
Gets or sets the password to use when loading encrypted files (PDF, DOC, DOCX, XLS, XLSX, etc).
Syntax
C#
Objective-C
C++/CLI
Java
Python
public string Password { get; set; } 
@property (nonatomic, copy, nullable) NSString *password 
public String getPassword() 
public void setPassword(String value) 
public: 
property String^ Password { 
   String^ get(); 
   void set (    String^ ); 
} 
Password # get and set (CodecsDecryptOptions) 

Property Value

The password to use when loading encrypted files. The default value is null.

Remarks

Use an empty string or a null reference to disable the use of a password.

The RasterCodecs.DecryptPassword event can also be used to provide the password necessary to decrypt files.

If the source file is PDF, the password can also be provided using the RasterCodecs.Pdf.Load.Password property.

For more information, refer to Loading Encrypted Files and RasterCodecs.DecryptPassword event.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
private static void DecryptPasswordExample() 
{ 
 
   /* This example loads an encrypted file using the Decrypt password event */ 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      string srcFile = @"Encrypted.docx"; 
 
      // Create a DecryptPassword handler  
      EventHandler<CodecsDecryptPasswordEventArgs> decryptPasswordHandler = (sender, e) => 
      { 
         /* You can also bring up a message box informing the user that the 'e.FileName' file is encrypted and needs a password */ 
         e.Password = "MyPassword"; 
         /* Or you can set 'e.Cancel = true' to cancel the load */ 
      }; 
 
      // Install the DecryptPassword event handler 
      codecs.DecryptPassword += decryptPasswordHandler; 
 
      codecs.Options.Load.AllPages = true; 
 
      using (RasterImage image = codecs.Load(srcFile)) 
      { 
         /* check that the image is not null to make sure the operation was not cancelled */ 
         if (image != null) 
            codecs.Save(image, srcFile + ".tif", RasterImageFormat.TifLzw, 0); 
      } 
   } 
} 
 
import java.io.*; 
import java.net.*; 
import java.nio.file.Paths; 
import java.util.*; 
import java.time.Instant; 
import java.time.Duration; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.codecs.RasterCodecs.FeedCallbackThunk; 
import leadtools.drawing.internal.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.color.ChangeIntensityCommand; 
import leadtools.svg.*; 
 
 
public void decryptPasswordExample() { 
   // This example loads an encrypted file using the Decrypt password event // 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String srcFile = combine(LEAD_VARS_IMAGES_DIR, "Encrypted.pdf"); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Install the DecryptPassword event handler 
   codecs.addDecryptPasswordListener(decryptPasswordHandler); 
 
   codecs.getOptions().getLoad().setAllPages(true); 
 
   RasterImage image = codecs.load(srcFile); 
   // check that the image is not null to make sure the operation was not cancelled 
   // // 
   if (image != null) 
      codecs.save(image, srcFile + ".tif", RasterImageFormat.TIFLZW, 0); 
} 
 
// Create a DecryptPassword handler 
CodecsDecryptPasswordListener decryptPasswordHandler = new CodecsDecryptPasswordListener() { 
 
   @Override 
   public void onDecryptPassword(CodecsDecryptPasswordEvent e) { 
      // You can also bring up a message box informing the user that the 'e.FileName' 
      // file is encrypted and needs a password // 
      e.setPassword("MyPassword"); 
      // Or you can set 'e.Cancel = true' to cancel the load // 
 
   } 
 
}; 
Requirements

Target Platforms

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

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