How to convert a pdf to a memory stream

后端 未结 3 1095
自闭症患者
自闭症患者 2021-01-05 00:37

I am writing an application in MVC4.

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

3条回答
  •  旧时难觅i
    2021-01-05 01:13

    Worked it out

     var pdfContent = new MemoryStream(System.IO.File.ReadAllBytes(imageLocation));
                    pdfContent.Position = 0;
                    return new FileStreamResult(pdfContent, "application/pdf");
    

提交回复
热议问题