We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with opening encrypted pdf (password pdf).. need help..!

Hi,

I am trying to open a encrypted pdf(pdf with password) using syncfusion.

this PDF file is encrypted with AES, keysize is 256bit Revision 6. (result of debug)

code are like this
loadDocument =  new PDFLoadedDocument(buffer , pw);
~~
pdfViewer.LoadDocument(loadedDocument)

※AES 128bit is no problem

But after pdfviewer.LoadDocument();

it brings a unhandled error message. I tried to take these code in try {} catch phrase, but

it did no help. It seems to look like a xaml error but anyone could help me?

Thanks very much.



8 Replies

JP Jhansi Priya Ramesh Syncfusion Team November 29, 2019 12:55 PM UTC

Hi KimJiyun, 

We tried reproducing the issue “Unhandled exception occurs while loading the AES 256 encrypted PDF document” with the sample PDF document created from Syncfusion PDF library , but it is working fine as expected. Please find the sample application from below with which we tried to reproduce the issue in our end. 


We suspect that the issue may occur specifically with the PDF document you are using at your end. Kindly share the following details to analyze more on this issue and assist with better solution. 
1.       Simple sample or modify the above sample with which issue could be reproduced. 
2.       Sample PDF document in which issue could be reproduced. 
3.       SfPdfViewer version. 
4.       Exception details/Stacktrace details 

Regards, 
Jhansi Priya Ramesh 



KI KimJiyun December 2, 2019 08:45 AM UTC

I am really Thanks for your answer.

I have ran your sample code with my attached file and some of AES 256 bit encrypted pdf,

but it did not worked too.

could you try by my pdf sample and give me some other solutions?

I would be really glad. thanks.

(※password : amada)


Attachment: error256bit_61c2c4b0.zip


JP Jhansi Priya Ramesh Syncfusion Team December 3, 2019 10:16 AM UTC

Hi KimJiyun, 

Thank you providing the sample PDF document. We could able to reproduce the issue “Application crashes while loading an encrypted document” with the provided encrypted document. We have forwarded this issue to our development team for further analysis and we will update further details on 5th November 2019. 

Regards, 
Jhansi Priya Ramesh 



NK Navaneetha Kannan Sudalai Muthu Syncfusion Team December 5, 2019 03:47 PM UTC

Hi KimJiyun,  

The issue “Application crashes while loading an encrypted document” is not a defect in Syncfusion PDF Viewer. We use UWP platform’s PdfDocument API to convert PDF pages to images and display the images in the PDF Viewer. The exception is due to a bug in the PdfDocument API. Since this issue is specific to the PDF you have given, we need to post this bug on MSDN Windows Developer Center along with this PDF.  

Kindly let us know whether we can attach the PDF you have given while logging the bug in MSDN.  

For your reference, we have created a simple sample which reproduces this issue in PdfDocument. We have also attached another simple password protected PDF (Encrypted Document.pdf, password is “syncfusion”) with this sample. For this PDF there is no crash. The crash occurs only for the provided PDF (error256bit.pdf). The sample can be downloaded from the below link.  


Also, the Microsoft Edge application renders PDFs using this PdfDocument API. In Edge also, the error256bit.pdf is not able to be viewed. But the EncrypedDocument.pdf is shown.  

Best, 
Navaneetha Kannan 



RU RunSam October 21, 2021 07:13 AM UTC

There are two types of open encrypted PDF.

1: Open the protected PDF file with the original (correct) password.

2: Try to open an encrypted PDF file without knowing the password.

Solution:

1. If you want to open the PDF password without knowing the password, it is recommended to try Google Drvice, which is a free and safe method to delete the password on the PDF.

  https://drive.google.com/drive/

2. If you don't know the password, I suggest you try GuaPDF. It can delete any easy password from the PDF to open the encrypted PDF file.

https://www.guapdf.com/

By the way, if the password is too complicated, the most effective way is to use professional tools. In order to ensure the security of the data in the PDF file, this is the best choice. Recommend the software i have used here:

https://www.bestpdfpasswordremover.com/how-to-remove-password-from-pdf.html





VD Vikram Devaraj Syncfusion Team October 27, 2021 03:34 PM UTC

Hi RunSam,


Thank you for the suggestions.


Regards,
Vikram




OD oddssatisfy December 23, 2023 11:10 PM UTC

Hi Guys,

I have a taxation document - Form 26AS but it is password protected. Shall I upload it as it is delete PDF protection online? Is there a way I can mention the password somewhere while uploading documents ?


Thanks



MA ManojKumar Arumugasamy Syncfusion Team December 26, 2023 10:50 AM UTC

Hi oddssatisfy,

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.

 

If you still receive any issues kindly provide a PDF and password in this forum thread.


Regards,
Manoj Kumar.


Loader.
Live Chat Icon For mobile
Up arrow icon