2
Answers

Pdf View conversation failed

code:

string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"650\" height=\"800\">";
embed += "If you are unable to view file, you can download from <a href = \"{0}&download=1\">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("~/Handlers/Handler.ashx?type=test&Id=" + 1));

Handler code:

if (context.Request.QueryString["type"].ToLower() == "test")
{


string test = "hii sanjay";/* context.Session["sr"].ToString();*/
byte[] bytes =Encoding.UTF8.GetBytes(test);
ViewDocuments(context, bytes);
}

//Document View
public void ViewDocuments(HttpContext context, byte[] bytes)
{
if (bytes != null)
{
context.Response.Buffer = true;
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.ContentType = "application/pdf";
context.Response.BinaryWrite(bytes);
context.Response.Flush();
context.Response.End();
}
}

i written this code into handler

when click on view button

Failed to load PDF document i got this message

Answers (2)