c# - How to convert a pdf to a memory stream -


I am writing an application in MVC4.

I have a physical PDF file on the server, I want to convert it to a memory stream and send it back to the user like this:

  Return file ( Stream, "app / pdf", "ipdf pdf");   

But how do I convert a PDF file to the storage stream?

Thank you!

You do not need memorystream . The easiest way to overload the file name is to:

  return file (@ "c: \ mimefile pdf", "application / pdf");   

Another solution is to use overload which accepts byte [] :

  returns file (System.IO .File.ReadAllBytes (@ "C: \ MyFile PDF"), "Application / PDF");   

or if you want to use FileStream :

  Return file (new filestream (@ "C: \ MyFile PDF ", FileMode.Open, FileAccess.Read)," Application / PDF ");    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -