none
I am trying to write pdf bytes through c# in edge browser, it creates a pdf but the pdf loses all formatting and words get overlapped.

    Pertanyaan

  • Whenever I am trying to write pdf bytes in edge browser it loses all its formatting.

    I am getting the pdf bytes as an byte array from a service and then writing those pdf bytes in browser to get the pdf.

    I am using the below code for that.

    Response.Clear();
    
    Response.ClearHeaders();
    
    Response.ClearContent();
    
    Response.Buffer = true;
    
    stringfileName = pn + ".pdf";
    
    Response.AddHeader("Accept-Header", bytes.Length.ToString());
    
    Response.AddHeader("Content-Length", bytes.Length.ToString());
    
     
    Response.AddHeader("Content-Disposition", "attachment;filename="+ fileName);
    
    Response.AddHeader("Pragma", "public");
    
    Response.AddHeader("Expires", "0");
    
    Response.AddHeader("Cache-Control", "public");
    
    Response.AddHeader("Cache-Control", "max-age=0");
    
    Response.ContentType = "application/pdf";
    
    Response.AddHeader("Accept-Ranges", "bytes");
    
    Response.BinaryWrite(bytes);
    
    Response.Flush();
     
    Response.SuppressContent = true;
    


    • Dipindahkan oleh CoolDadTx Selasa, 04 September 2018 13.47 ASP.NET related
    Selasa, 04 September 2018 09.54

Semua Balasan

  • Whenever I am trying to write pdf bytes in edge browser it loses all its formatting.

    I am getting the pdf bytes as an byte array from a service and then writing those pdf bytes in browser to get the pdf.

    I am using the below code for that.

    Response.Clear();
    
    Response.ClearHeaders();
    
    Response.ClearContent();
    
    Response.Buffer = true;
    
    stringfileName = pn + ".pdf";
    
    Response.AddHeader("Accept-Header", bytes.Length.ToString());
    
    Response.AddHeader("Content-Length", bytes.Length.ToString());
    
     
    Response.AddHeader("Content-Disposition", "attachment;filename="+ fileName);
    
    Response.AddHeader("Pragma", "public");
    
    Response.AddHeader("Expires", "0");
    
    Response.AddHeader("Cache-Control", "public");
    
    Response.AddHeader("Cache-Control", "max-age=0");
    
    Response.ContentType = "application/pdf";
    
    Response.AddHeader("Accept-Ranges", "bytes");
    
    Response.BinaryWrite(bytes);
    
    Response.Flush();
     
    Response.SuppressContent = true;


    Here "bytes" is the pdf byte array 
    Selasa, 04 September 2018 09.58
  • Please post questions related to web development in the ASP.NET forums.

    Michael Taylor http://www.michaeltaylorp3.net

    Selasa, 04 September 2018 13.47