Render Pdf bytes array within browser in MVC

Render Pdf within browser

There are different ways to render Pdf in a browser. In this I’m explaining to render Pdf by fileContent/byte array. In a below example I’m using Index Action which returns the FileContentResult.

public ActionResult Index()
{
Response.Clear();
Response.AddHeader(“Content-Disposition”,“inline; filename=sample.pdf”);
Response.AddHeader(“Content-Type”,“application/pdf”);
Response.ClearHeaders();
Response.AddHeader(“Content-Length”, byteArray.Length.ToString());
FileContentResult result = new FileContentResult(byteArray, “application/pdf”);
return result;
}

That’s it from controller side. Now you have to call you Action to get it rendered on your HTML. You can use different HTML5 tags like :

<iframe>
<iframe src = @Url.Action(“Index”, “Home”)#zoom=150′ width = “100%” height=”525″ id=”iFramePdf” #zoom=”200″ frameBorder=”1″></iframe>

<embed>
<embed src=’@Url.Action(“Index”, “Home”)#zoom=150′ width = “100%” height=”525″ id=”iFramePdf” #zoom=”200″ frameBorder=”1″ type=”application/pdf”/>

<object>
<object data=’@Url.Action(“Index”, “Home”)#zoom=150′ width = “100%” height=”525″ id=”iFramePdf” #zoom=”200″ frameBorder=”1″ type=”application/pdf”>
</object>

Hope this article will help you.

How to achieve multithreading in Java Script

Achieve Multithreading in Java Script

Alright, before we start let me admit that JavaScript is a single-threaded environment, JavaScript historically suffers from an important limitation that all its execution process remains inside a single thread.

On the web you may found the various ways to archive multi-threading but as far as I know, the only way is HTML5 Web Workers. You can simulate ‘concurrency’ by using techniques like setTimeout(),setInterval() and event handlers.

Yes, all of these features run asynchronously, but non-blocking doesn’t necessarily mean concurrency. Like setInterval() only schedule things to happen later, they don’t run concurrently with anything else. Before multithreading when executing scripts in an HTML page, the page becomes unresponsive until the script is finished.

Multithreading using HTML5 Web Workers

Continue reading “How to achieve multithreading in Java Script”

Export to excel table without hitting server using Jquery

Want to export the data to excel, but don’t  want to hit server again and again ?? So here is the simple way out for you.

In the following steps you will understand how simply we can export the data to excel sheet by using jquery.

Continue reading “Export to excel table without hitting server using Jquery”

HTML5 Local Storage and Session Storage

HTML5Local Storage and Session Storage

Before HTML5, application data of web applications are stored in cookies. In this article I will explain you what is Local Storage and Session Storage Object, How we can use it our application, What is the difference between Local and Session Storage object. Why HTML Local Storage better than cookies. So lets  start with What .

Continue reading “HTML5 Local Storage and Session Storage”

How to use Mailto link in HTML

 What is Mailto Link ???

Mailto link is  basically a type of HTML link that opens a new mail window by activating the default mail client installed in your PC .

 

  • Now let us suppose you want to send mail to a single person using mailto link then you have to write code as :

Continue reading “How to use Mailto link in HTML”