i want to open the PDF file in new tab when i display it on the web. but without clicking just a function that open the file in a new tab. this is my display function:
private void DisplayPage()
{
string path = CanvasWritingStepImages._pdfName;
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);
if (buffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "inline; filename=Formulike.pdf");
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
else
{
logger.Error("Buffer was Null!");
throw new Exception("PDF ERROR");
}
}
i'm using "iTextSharp" to work with the PDF file. it's important that the PDF file will be open on a new tab without any clicking just by the function. i just found with button click that open a new tab.
i tried this: How to open PDF file in a new tab or window instead of downloading it (using asp.net)?