How to open bytes of pdf in a new browser tab

Asked

Viewed 1,503 times

1

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

    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 don’t want to download, I want it to be opened in a new tab the bytes.

1 answer

1


You don’t directly control this - I, for example, have Firefox set up to download all of them. pdf automatically - but you can try to put inline in place of attachment:

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

To open the document in a new flap, you can put target="_blank" on the link accessing the PDF.

  • Solved! thanks a lot.

  • target Blank opens a blank tab

Browser other questions tagged

You are not signed in. Login or sign up in order to post.