I would recommend creating another action on the controller specifically for rendering PDF data . Then it's just a matter of referencing it in your data attribute:
data="@Url.Action("GetPdf", "PDF")"
I'm not sure if you can dump raw PDF data in the DOM without affecting any coding problem. You can do as images, although I have never tried. But, for demonstration and image it will look like this:
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
So, assuming this can be done , it will probably look like this:
@{ String base64EncodedPdf = System.Convert.ToBase64String(Model.pdfInBytes); } @* ... *@ <object data="data:application/pdf;base64,@base64EncodedPdf" width="900" height="600" type="application/pdf"></object>
I still support my original answer to create a new action.
source share