问题
I have an application that displays password protected PDFs using iTextSharp.
pdfCopy.SetEncryption(true, "Secretinfo", "Secretinfo", 0);
If the user saves the PDF, the saved copy of the PDF is password protected. Which is great. The problem is it also prompts for password before displaying the PDF on the browser. Which isn't good.
So I'm thinking maybe it's possible to supply the password using javascript just to display it on the browser. It's bad practice but I don't see that I have any other choice. I'm no good at JavaScript. Maybe someone here can help me?
But hey if you have another idea of how to best approach my problem, please do tell!
Here's what I need to happen:
Display the PDF on the browser without it prompting for password. But I need the saved copy to be password protected. No edit, print or copy. Not even view. Unless the user supplies the password.
来源:https://stackoverflow.com/questions/17719629/javascript-to-automatically-supply-password