mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.51k stars 9.98k forks source link

Is there a PASSWORD variable , to decrypt encrypted PDFs ? #3298

Closed mahmoudfelfel closed 11 years ago

mahmoudfelfel commented 11 years ago

Hi, please i want to know how to set an encrypted PDF password directly , something like that : DEFAULT_URL : ' the encrypted pdf url ' , PASSWORD : ' the password '

currently i am using this :

$(document).ready(function(){ PDFView.open('the encrypted pdf url ','scale', 'the password'); });

and it doesn't work except it wrapped by document ready , and the problem is that the pdf takes a long time still the whole document loaded and then started loading and rendering the pdf ,but when i am using the DEFAULT_URL it loaded faster . thanks,

gigaherz commented 11 years ago

There shouldn't be any difference between default url and the ready code... maybe it was cached when you tested or something like that?

yurydelendik commented 11 years ago

Please provide the URL to the example and comment what was changed in standard viewer. PDFView.open() is called on "document ready" by default (https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L3561) not sure why you are using jQuery?

timvandermeij commented 11 years ago

I might not understand your question correctly, but why password-protect your PDF files if you're going to give away the password in the JavaScript source code? You might as well remove the password protection then...

yurydelendik commented 11 years ago

Is there a PASSWORD variable , to decrypt encrypted PDFs ?

No. But you can add one at the viewer.js top and use it at https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L3608

Closing as answered