BoldDesk®Customer service software with ticketing, live chat & omnichannel support, starting at $99/mo for unlimited agents. Try for free!
Hi Shompinice,
We could see in your provided sample that you didn't
handle loading the password protected documents. If you are trying to load the
encrypted document without a password, it will throw a PDFException. To load
the encrypted document, please follow the below steps:
To find the encrypted document, you need to use a try-catch block while loading.
Way -1
try { ldoc = new PdfLoadedDocument(stream); pdfViewer.LoadDocument(fileStream); } catch (PdfException pdfException) { if (pdfException.Message == "Can't open an encrypted document. The password is invalid.") { var password = "XYZ"; pdfViewer.LoadDocument(fileStream, password); } } |
Way -2
try { ldoc = new PdfLoadedDocument(stream); pdfViewer.LoadDocument(fileStream); } catch (PdfException pdfException) { if (pdfException.Message == "Can't open an encrypted document. The password is invalid.") { ldoc = new PdfLoadedDocument(stream, password); pdfViewer.LoadDocument(ldoc); } } |
Note: Currently, we don’t have support to show the default password popup in
our control. You can create your own password popup if needed and using that
entered password text, you can load the encrypted document with the above
suggestion.
After a week of hard work... I tried to create a password input box myself but failed, could you guys provide a copy of a modified solution as you demonstrated?
In theory it should also contain a detection that should not pop up a dialog box when the DPF file is not encrypted
password is:
ymky-edu.taobao.com
fjnu611805-【2】真题及参考答案.pdf
After a week of hard work... I tried to create a password input box myself but failed, could you guys provide a copy of a modified solution as you demonstrated?
In theory it should also contain a detection that should not pop up a dialog box when the DPF file is not encrypted
password is:
ymky-edu.taobao.com
fjnu611805-【2】真题及参考答案.pdf
Hi Shompinice,
We have created a sample based on your requirement to load the encrypted document using a password entry popup and attached the sample for the same below. We have simply created a password entry popup to demonstrate your requirements. However, with the same provided logic, you can customize your own password entry popup.
Is it possible to create the password dialog using XAML in the example instead of using C#? I'm not very familiar with customizing styles in C#, and using XAML I would be able to modify it to conform to Windows design guidelines.
Original project without password dialog
https://www.syncfusion.com/downloads/support/forum/185591/ze/PDFViewer_a218362e
The project you modified in your previous reply
https://www.syncfusion.com/downloads/support/forum/185885/ze/PDFViewer_48659a4
Hi Shompinice,
We have modified the sample to create a password dialog using XAML. Kindly find the sample in the following link, https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfViewer_1126160908
With your help, I modified the look based on yours so that it looks like it gets a consistent look with Windows 11. this looks awesome
Thank you for your reply. I'm glad to hear that the issue you were experiencing has been resolved. We're marking this ticket as closed.
If you have any other questions or concerns, please don't hesitate to contact us.