Decrypt Method (original) (raw)
Summary
Decrypt this document using the specified password.
Syntax
public:
bool Decrypt(
String^ _password_
)
Parameters
password
String containing the password phrase to decrypt this document.
Example
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Document.Writer;
using Leadtools.Document;
using Leadtools.Caching;
using Leadtools.Annotations.Engine;
using Leadtools.Ocr;
using Leadtools.Barcode;
using Leadtools.Document.Converter;
public void DocumentIsEncryptedExample()
{
// This is the password for this encrypted document
string password = "lead";
var options = new LoadDocumentOptions();
using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Protected.pdf"), options))
{
if (document.IsEncrypted && !document.IsDecrypted)
{
Console.WriteLine("Encrypted Document, decrypting it...");
// Decrypt it now
document.Decrypt("lead");
}
// Should not be encrypted anymore
System.Diagnostics.Debug.Assert(!document.IsEncrypted);
}
// Or, set the password directly in the load options
options.Password = password;
using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Protected.pdf"), options))
{
// Should not be encrypted
System.Diagnostics.Debug.Assert(!document.IsEncrypted);
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";
}