I have the following code that after a PDF is generated submitting a query to SQL will display in browser. But I am looking is to display the file in a PDF viewer in the page and not using the browser reader. The viewer is inside a DIV. You can see the example shown in the image attached, which I run as test to show the file from the local system and not streaming. This function Response.BinaryWrite(bytes); sends the generated PDF to the browser viewer. How can I do for it to display in the viewer inside the DIV instead?
string reportLabel = lbReports.Text;
document.Add(table);
document.Close();
byte[] bytes = memoryStream.ToArray();
Response.Clear();
Response.AddHeader("Content-Disposition", "inline");
Response.Buffer = true;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.BinaryWrite(bytes);
This is the code that should show the generated PDF file in the DIV:
string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"698px\" height=\"450px\">";
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, ("blabla.pdf")); /*it shows this PDF as local file just for test*/
memoryStream.Close();
this.Context.ApplicationInstance.CompleteRequest();
Image here: sample
The idea is to have the file generated temporarily and the user will decide if saving it or not. I have tried other options, but none seems to work, especially if it is inside a DIV. In other words, I am looking to display the dynamic PDF file using ltEmbed.Text = string.Format(embed, ...);