Indicates whether this document is encrypted.
public bool IsEncrypted { get; }
Public ReadOnly Property IsEncrypted() As Boolean
Get
public:
property bool IsEncrypted
{
bool get()
}
public boolean isEncrypted()
true if this document is encrypted, otherwise; false.
In most cases, the Document is ready to use after it has been obtained. However, some documents such as PDF can be encrypted and required a password before it can be parsed and used. Most of the properties and methods of Document will throw an error if the document has not been decrypted. IsEncrypted can be used to check if 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 Documents Library.
This example will show how to open an encrypted document.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms.DocumentWriters;
using Leadtools.Svg;
using Leadtools.Documents;
using Leadtools.Caching;
using Leadtools.Annotations.Core;
using Leadtools.Forms.Ocr;
using Leadtools.Barcode;
public static void DocumentIsEncryptedExample()
{
// This is the password for this encrypted document
string password = "lead";
var options = new LoadDocumentOptions();
using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "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(ImagesPath.Path, "Protected.pdf"), options))
{
// Should not be encrypted
System.Diagnostics.Debug.Assert(!document.IsEncrypted);
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Forms.DocumentWriters
Imports Leadtools.Svg
Imports Leadtools.Documents
Imports Leadtools.Caching
Imports Leadtools.Annotations.Core
Imports Leadtools.Barcode
Imports Leadtools.Forms.Ocr
<TestMethod()>
Public Shared Sub DocumentIsEncryptedExample()
' This Is the password for this encrypted document
Dim password As String = "lead"
Dim options As New LoadDocumentOptions()
Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options)
If document.IsEncrypted AndAlso (Not document.IsDecrypted) Then
Console.WriteLine("Encrypted Document, decrypting it...")
' Decrypt it now
document.Decrypt("lead")
End If
' Should Not be encrypted anymore
System.Diagnostics.Debug.Assert(Not document.IsEncrypted)
End Using
' Or, set the password directly in the load options
options.Password = password
Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options)
' Should Not be encrypted
System.Diagnostics.Debug.Assert(Not document.IsEncrypted)
End Using
End Sub
Products |
Support |
Feedback: IsEncrypted Property (Document) - Leadtools.Documents |
Introduction |
Help Version 19.0.2017.3.22
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.