I'm trying to display PDF in a new tab after submitting a form. However, exporting a PDF takes a while so when users click export, new blank tab opens and there's no clear indication what is happening.
To open form result in a new tab I'm using:
@using (Html.BeginForm("Export", "Reviews", FormMethod.Post, new { target = "_blank" } ))
and method in the controller is:
public FileStreamResult Export(int presentationID, int[] selectedViews)
{
...
return new FileStreamResult(stream, "application/pdf");
}
Is there a way to put a preloader in body of a new tab or open a tab only after PDF is ready to display? I don't want to use window.open()
as this creates a popup which is blocked by default.
Ajax File download Issue describes similiar problem but in my case I don't want the PDF to be downloaded but opened in a new tab.