IsEncrypted Property (original) (raw)
Summary
Gets a value that indicates whether this document is encrypted.
Syntax
public bool IsEncrypted {get;}
public:
property bool IsEncrypted
{
bool get()
}
public boolean isEncrypted()
Property Value
true if this document is encrypted; otherwise, false.
Example
This example will show how to open an encrypted document.
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";
}