Currently I have a pdf that has several sheets in a database stored path, and what I do is get a new pdf with a file from the server file and what I need is to show that pdf in a new window without needing to download the file, what I get now is the download of the file:
//Existe el pdf en el servidor se agrega logica de negocio para retornar el traveler
string ruta = Path.Combine(Proyecto.pathPDF, "ODT " + dtSpools.Rows[0][0].ToString() + ".pdf");
int numeroPaginasPDF = SplitPDF.Instance.CantidadDePaginas(ruta) - int.Parse(dtSpools.Rows[0][2].ToString());
Document doc = new Document();
string nombreTemporal = "\ODT_" + NumeroControl + ".pdf";
MemoryStream stream = new MemoryStream();
Document document = new Document();
PdfCopy writer = new PdfCopy(document, stream);
writer.CloseStream = false;
PdfImportedPage page = null;
document.Open();
PdfReader reader = new PdfReader(ruta);
page = writer.GetImportedPage(reader, numeroPaginasPDF);
writer.AddPage(page);
document.Close();
reader.Close();
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=ODT_" + NumeroControl + ".pdf");
//Response.Buffer = true;
//Response.OutputStream.Write(stream.GetBuffer(), 0, stream.GetBuffer().Length);
//Response.OutputStream.Flush();
//Response.Flush();
//Response.Close();
//Response.End();
//return new FileStreamResult(Response.OutputStream, "application/pdf");
Response.BinaryWrite(stream.ToArray());
return File(stream.ToArray(), "application/pdf");
and I send it to execute with the following link:
<td><a href='/LinkTraveler/ObtenerPDFTraveler/[email protected](a => a.NumberControl)&[email protected](b => b.ProjectID)' target="_blank">@Html.DisplayTextFor(m => m.NumberControl)</a></td>
I would thank you in advance for your help