Guest User

Untitled

a guest
Jun 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. System.Diagnostics.Process p = new System.Diagnostics.Process();
  2. p = new System.Diagnostics.Process();
  3.  
  4. p.StartInfo.FileName = CreatePDF(); // method that creats my pdf and returns the full path
  5.  
  6. try
  7. {
  8. if (!p.Start())
  9. Controller.Error = "Opening acrobat failed..";
  10. }
  11. catch(Exception ex)
  12. {
  13. Controller.Error = "Create PDF::" + ex.Message;
  14. }
  15.  
  16. Response.ContentType = "application/pdf";
  17. Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", file.FileName));
  18. Response.BinaryWrite(file.FileBytes);
  19. Response.Flush();
  20. Response.End();
  21.  
  22. var stream = GetTheFileAsStream();
  23. var attachment = new Attachment(stream);
  24.  
  25. using (Process p = new Process())
  26. {
  27. p.StartInfo.RedirectStandardOutput = false;
  28. p.StartInfo.FileName = @"C:foo.pdf";
  29. p.StartInfo.UseShellExecute = true;
  30. p.Start();
  31. p.WaitForExit();
  32. }
  33.  
  34. public ActionResult GetFile()
  35. {
  36. return File("foo.pdf", "application/pdf");
  37. }
Add Comment
Please, Sign In to add comment