ASP.NET MVC Generate PDF from byte[]

末鹿安然 提交于 2019-12-01 14:54:05

Assuming that the byte array you have represents a valid PDF then in your controller action you could serve this PDF by returning the proper ActionResult with the correct Content-Type response header:

public ActionResult ShowPDF(string personid)
{ 
    //call service and get data
    string fileContent = response.FileContent;
    byte[] data = Convert.FromBase64String(fileContent);

    **// Here using data I need to show PDF in new window**
    return File(data, "application/pdf");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!