Reputation: 11
My issue is I'm currently receiving from a web service response a string that is the binary data of a PDF file. I need to display this PDF file embedded in an MVC view. I'm using C#.
Any pointers are appreciated.
Upvotes: 1
Views: 7034
Reputation: 309
HTML5 has added the embed tag which allows a variety of rich content to be embedded into the page as follows:<embed src="your file path here" type="application/pdf" />
Upvotes: 0
Reputation: 13419
You can just return it using File. Something like this:
public ActionResult ShowPDF()
{
byte[] pdf = myService.GetPDF();
return File(pdf, "application/pdf");
}
UPDATE
Create a page containing a iframe
element and set the src
attribute to point to your view that renders the PDF file. Here is an example taken from here
<iframe src="ShowPDF" width="100%" style="height:20em">
[Your browser does <em>not</em> support <code>iframe</code>,
or has been configured not to display inline frames.
You can access <a href="ShowPDF">the document</a>
via a link though.]
</iframe>
Upvotes: 1