Gets a value that indicates whether this document is encrypted.
public bool IsEncrypted {get;} Public ReadOnly Property IsEncrypted() As BooleanGet
public:property bool IsEncrypted{bool get()}
public boolean isEncrypted()
true if this document is encrypted; otherwise, false.
In most cases, the LEADDocument is ready to use after it has been obtained. However, some documents such as PDF can be encrypted, and require a password before it can be parsed and used. Most of the properties and methods of LEADDocument will throw an error if the document has not been decrypted. IsEncrypted can be used to check whether the document is encrypted and if so, Decrypt must be called with a password obtained from the user to unlock the document. When that happens, the value of IsDecrypted becomes true and the document is ready to be used. Note that IsEncrypted will stay true to indicate the original state of the document.
For more information, refer to Loading Encrypted Files Using the Document Library.
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 documentstring 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 nowdocument.Decrypt("lead");}// Should not be encrypted anymoreSystem.Diagnostics.Debug.Assert(!document.IsEncrypted);}// Or, set the password directly in the load optionsoptions.Password = password;using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Protected.pdf"), options)){// Should not be encryptedSystem.Diagnostics.Debug.Assert(!document.IsEncrypted);}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.Document.WriterImports Leadtools.SvgImports Leadtools.DocumentImports Leadtools.CachingImports Leadtools.Annotations.EngineImports Leadtools.BarcodeImports Leadtools.OcrImports LeadtoolsDocumentExamples.LeadtoolsExamples.CommonImports Leadtools.Document.ConverterPublic Shared Sub DocumentIsEncryptedExample()' This Is the password for this encrypted documentDim password As String = "lead"Dim options As New LoadDocumentOptions()Using document As Leadtools.Document.LEADDocument = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options)If document.IsEncrypted AndAlso (Not document.IsDecrypted) ThenConsole.WriteLine("Encrypted Document, decrypting it...")' Decrypt it nowdocument.Decrypt("lead")End If' Should Not be encrypted anymoreSystem.Diagnostics.Debug.Assert(Not document.IsEncrypted)End Using' Or, set the password directly in the load optionsoptions.Password = passwordUsing document As Leadtools.Document.LEADDocument = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options)' Should Not be encryptedSystem.Diagnostics.Debug.Assert(Not document.IsEncrypted)End UsingEnd Sub
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
