HI All,
I have protected PDF Files in one folder i want to read that PDF by providing password automatically through code without any user manually input.Please I request you to help me out to solve this issue(when i am trying to do i am getting Bad user Password Error),
Thanks in advance
I am using this code to execute
string WorkingFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string InputFile = Path.Combine(WorkingFolder, "zr1VSB.pdf");
string OutputFile = Path.Combine(WorkingFolder, "zr1VSB_enc.pdf");
using (Stream input = new FileStream(InputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
{
PdfReader reader = new PdfReader(input);
PdfEncryptor.Encrypt(reader, output, true, "zr1VSB", "secret", PdfWriter.ALLOW_SCREENREADERS);
}
}