Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Documents Namespace > Document Class : IsEncrypted Property |
public bool IsEncrypted {get;}
'Declaration
Public ReadOnly Property IsEncrypted As Boolean
public boolean isEncrypted()
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.
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 Sub DocumentIsEncryptedExample() Dim options As New LoadDocumentOptions() options.UseCache = False 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") End If End Using options.Password = "lead" Using document As Leadtools.Documents.Document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options) If document.IsEncrypted AndAlso document.IsDecrypted Then Console.WriteLine("Decrypted Document") End If End Using End Sub
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; [TestMethod] public void DocumentIsEncryptedExample() { var options = new LoadDocumentOptions(); options.UseCache = true; using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options)) { if (document.IsEncrypted && !document.IsDecrypted) { Console.WriteLine("Encrypted Document"); } } options.Password = "lead"; using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Protected.pdf"), options)) { if (document.IsEncrypted && document.IsDecrypted) { Console.WriteLine("Decrypted Document"); } } }