Skip to content

Commit

Permalink
Added the security sample
Browse files Browse the repository at this point in the history
  • Loading branch information
jeyalakshmit committed Aug 14, 2023
1 parent b596e95 commit 7ebec1e
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
FileStream docStream = new FileStream(Path.GetFullPath("../../../Input.pdf"), FileMode.Open, FileAccess.Read);

//Load the PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream, "password");
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);

//Write whether document is protected or not in console window.
Console.WriteLine("The PDF document is password protected one");
}

catch (PdfDocumentException exception)
catch (PdfException exception)
{
//Write whether document is protected or not in console window.
Console.WriteLine("The PDF document is not password protected");
if (exception.Message == "Can't open an encrypted document. The password is invalid.")
{
Console.WriteLine("Cannot open an encrypted document without password");
}
}

Console.ReadLine();

0 comments on commit 7ebec1e

Please sign in to comment.