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.

  • Thread starter Thread starter SudGupta89
  • Start date Start date
S

SudGupta89

Guest
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;

Continue reading...
 
Back
Top