The PDF downalod is executed correctly (minimized in the bottom corner of the browser).
How do you open automatically on a new tab ?:
<a href="#" class="download" name="downloaditem" id="downloaditem3" target="_blank"><span style="cursor:pointer"><font color="red"><b>BAIXADA</b></font></span></a>
This question looks something like this How to open the RazorPDF report in a separate tab , however I am using another PDF generator Pechkin , I added the target="_blank"
in the link as above, but it does not work.
This is the Action that generates the PDF:
[HttpPost]
public ActionResult PDFUmDocSelecionado(ProcessamentoRegistros pProcessamentoRegistros)
{
try
{
string _nomeArquivo = "Meu_Documento_" + DateTime.Now.ToString().Replace(" ", "_").Replace("/", "_").Replace(":", "_") + ".pdf";
DataTable _Dt = new DataTable();
_Dt = _IRepositorio.ObterHTML(pProcessamentoRegistros);
DataRow foundRow = _Dt.Rows[0];
var pechkin = Factory.Create(new GlobalConfig());
var pdf = pechkin.Convert(new ObjectConfig()
.SetLoadImages(true).SetZoomFactor(1)
.SetPrintBackground(true)
.SetScreenMediaType(true)
.SetCreateExternalLinks(true)
.SetIntelligentShrinking(true).SetCreateInternalLinks(true)
.SetAllowLocalContent(true), foundRow.ItemArray[0].ToString());
using (MemoryStream file = new MemoryStream())
{
file.Write(pdf, 0, pdf.Length);
}
byte[] arquivo = pdf;
//Response.Clear();
//Response.ClearContent();
//Response.ClearHeaders();
//Response.ContentType = "application/pdf";
////Response.AddHeader("Content-Disposition", string.Format("attachment;filename=arquivo.pdf, size={0}", _pdf.Length));
//Response.AddHeader("Content-Disposition", string.Format("inline;filename=" + _nomeArquivo + ", size={0}", pdf.Length));
//Response.BinaryWrite(pdf);
//Response.Flush();
//Response.End();
////return RedirectToAction("Index", "Documento");
return File(arquivo, System.Net.Mime.MediaTypeNames.Application.Octet, _nomeArquivo);
}
catch
{
return RedirectToAction("Index", "ProcessamentoRegistros");
}
}