2
The downalod from the PDF is executed correctly (is minimized at the bottom corner of the browser).
How to make it open automatically in a new guide ?:
<a href="#" class="download" name="downloaditem" id="downloaditem3" target="_blank"><span style="cursor:pointer"><font color="red"><b>BAIXADA</b></font></span></a>
That doubt is similar to that How to open the Razorpdf report in a separate tab, but I’m using another PDF generator Pechkin, I added the target="_blank"
link as above, but 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");
}
}
thanks for the answer but the example that is in Github error when click on the PDF download button:
Não é possível acessar um fluxo fechado.
– hard123
@Adrianosuv, test now, I’ve made an edit and I’ve uploaded a change to Github.
– George Wurthmann
all right ! Congratulations !
– hard123