Posted by a ceTe Software moderator
Hello,
There is no option available in DynamicPDF Viewer API to detect whether the PDF is password protected or not. You can load the PDF using PdfDocument class constructor by specifying empty string as password . If the PDF being loaded is password protected then the Viewer API throws InvalidPasswordException. You can catch this error and decide on further process. Below is the code sample for catching InvalidPasswordException while loading the PDF.
try
{
PdfDocument pdf = new PdfDocument(@"Path for PDF", "");
pdfViewer1.Open(pdf);
}
catch (InvalidPasswordException ex)
{
MessageBox.Show("PDF is password protected");
}
Thanks,
ceTe Software Support Team.