In this article I will explain with an example, how to implement PDF Viewer in ASP.Net by embedding PDF file on Web Page using C# and VB.Net.
The PDF file will be embedded on Web Page using HTML OBJECT Tag in ASP.Net.
 
 
HTML Markup
The HTML Markup consists of an ASP.Net LinkButton and a Literal control.
<asp:LinkButton ID="lnkView" runat="server" Text="View PDF" OnClick="View"></asp:LinkButton>
<hr />
<asp:Literal ID="ltEmbed" runat="server" />
 
 
Embed PDF file on Web Page in ASP.Net
The below event handler is raised when the View LinkButton is clicked. Here I am making use of HTML OBJECT Tag to embed PDF in browser. An HTML string of an OBJECT tag is generated in which the path of the PDF file is set.
The HTML string is then set to the Literal Tag.
To know more about Literal control, please visit Difference between Label and Literal control in ASP.Net.
C#
protected void View(object sender, EventArgs e)
{
    string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"500px\" height=\"300px\">";
    embed += "If you are unable to view file, you can download from <a href = \"{0}\">here</a>";
    embed += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file.";
    embed += "</object>";
    ltEmbed.Text = string.Format(embed, ResolveUrl("~/Files/Mudassar_Khan.pdf"));
}
 
VB.Net
Protected Sub View(sender As Object, e As EventArgs)
    Dim embed As String = "<object data=""{0}"" type=""application/pdf"" width=""500px"" height=""300px"">"
    embed += "If you are unable to view file, you can download from <a href = ""{0}"">here</a>"
    embed += " or download <a target = ""_blank"" href = ""http://get.adobe.com/reader/"">Adobe PDF Reader</a> to view the file."
    embed += "</object>"
    ltEmbed.Text = String.Format(embed, ResolveUrl("~/Files/Mudassar_Khan.pdf"))
End Sub
 
 
Screenshots
Adobe PDF Reader installed
PDF Viewer ASP.Net: Embed PDF file on Web Page in ASP.Net using C# and VB.Net
 
Adobe PDF Reader not installed
PDF Viewer ASP.Net: Embed PDF file on Web Page in ASP.Net using C# and VB.Net
 
 
Demo
 
 
Downloads