How to Open .pdf on a new Tab

user1520494 picture user1520494 · Apr 11, 2013 · Viewed 85k times · Source

The Objective:

I have to print a PDF on a new tab after some tasks have finished correctly.

Steps: I want to execute a method that should go to the server, take the PDF and open it on a new Tab, I was trying with these but is not working:

Controller: Export

 public ActionResult PrintPdf()
    {
        Response.AppendHeader("Content-Disposition", "inline; filename= " + MyClassPdfWriter.GetFileName);
        return File(MyClassPdfWriter.GetMemoryStream, "application/pdf");
    }

View:

function TasksSucced(){
      $.get('@Url.Action("PrintPdf", "Export", "new {target = _blank}")');
}

Answer

user1520494 picture user1520494 · Apr 11, 2013

Solved! That works for me

 window.open('/Export/PrintPdf');