How to open save dialog box for saving pdf

Posted by Mutturaj Bali on Stack Overflow See other posts from Stack Overflow or by Mutturaj Bali
Published on 2012-03-31T11:08:00Z Indexed on 2012/03/31 11:29 UTC
Read the original article Hit count: 243

Filed under:
|

I truly appreciate your suggestions. I am using MVC3 and I want user to save to his own path by opening a dialog with password protected. Can you guys please help me on this.

Below is my code:

mydoc.GenerateLetter(PdfData);               

string WorkingFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

using (MemoryStream m = new MemoryStream())
{
   m.Write(mydoc.DocumentBytes, 0, mydoc.DocumentBytes.Length);
   m.Seek(0, SeekOrigin.Begin);
   string OutputFile = Path.Combine(WorkingFolder, PdfData.Name + ".pdf");

   using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
   {
      PdfReader reader = new PdfReader(m);
      PdfEncryptor.Encrypt(reader, output, true, "abc123", "secret", PdfWriter.ALLOW_SCREENREADERS);
   }
}       

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc-3