Gets or sets the password to use when loading encrypted files.
public string Password {get; set;}
public:
property String^ Password
{
String^ get()
void set(String^ value)
}
Password # get and set (CodecsDecryptPasswordEventArgs)
Set this property to the correct password necessary for loading this encrypted file. Default value is a null string.
The RasterCodecs.DecryptPassword event might get fired again if the password is incorrect or if you try to open another encrypted file. The CodecsDecryptPasswordEventArgs.FileName property indicates which file triggered the event (and for which you need to provide the password).
For example, you attempt the sequence of operations below:
Registering a RasterCodecs.DecryptPassword event handler to be used for all loads and not setting the correct password using other means (RasterCodecs.Options.Load.Decrypt.Password or RasterCodecs.Pdf.Options.Load.Password)
Loading unencrypted.pdf
Loading encrypted-pass1.docx
which fires the RasterCodecs.DecryptPassword event with CodecsDecryptPasswordEventArgs.FileName = "encrypted-pass1.docx". In this case, you need to set Password = pass1
Loading unencrypted.xlsx
Loading encrypted-pass2.xlsx
which fires RasterCodecs.DecryptPassword event with CodecsDecryptPasswordEventArgs.FileName = "encrypted-pass2.xlsx". In this case, you need to set Password = pass2
The above sequence shows that it is important to pay attention to the FileName property as it will contain the file name without a password.
Refer to RasterCodecs.DecryptPassword event for more information.
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);
}
}
}
RasterCodecs.DecryptPassword event
CodecsDecryptPasswordEventArgs.FileName
CodecsDecryptPasswordEventArgs Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document