How to open pdf bytes in a new tab in the browser

1

I have the bytes of a report in pdf but I just found how to download it.

    byte[] bytes = Relatorio.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


        HttpResponse response = HttpContext.Current.Response;
        response.Clear();
        response.ContentType = "PDF";
        response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}", "PDF"));
        response.OutputStream.Write(bytes, 0, bytes.Length);
        response.End();

I do not want to download, I want the bytes to be opened in a new tab.

    
asked by anonymous 09.06.2015 / 15:13

1 answer

1

You do not directly control this - I, for example, have Firefox set to download all .pdf files automatically - but you can try to put inline instead of attachment :

response.AddHeader("Content-Disposition", string.Format("inline; filename={0}", "PDF"));

To open the document in a new tab, you can put target="_blank" on the link that accesses the PDF.

    
09.06.2015 / 15:29