I am trying to embed a 2330 KB file on the web browser. Is their any way to display large pdf files.
Well, seems you are having issue on displaying large PDF file on browser. Obviously, you can. In fact, the way is much cleaner and efficient no matter how large the pdf is. I have checked with up to 10,000 KB size. Here is the implementation below:
Embed Large PDF:
Controller:
public IActionResult DisplayLargePdf()
{
using (MemoryStream stream = new MemoryStream())
{
string embed = "<object data="{0}" type="application/pdf" width="1000px" height="600px">";
embed += "If you are unable to view file, you can download from
embed += " or download
embed += "</object>";
TempData["Embed"] = string.Format(embed, "/YourFolderName/YourFileName.pdf");
return View();
}
}
View:
@Html.Raw(TempData["Embed"])
Output:
Browser Settings:
If your browser restricts you, in that scenario, you should configure your browser setting. For Edge you can configure as following.
Note:
The key part is <object data>
which would display PDF for you. I have tested just google chrome as well and working accordingly.