0

I need to display a pdf file in an ASP.NET Web Forms 4 application through an ascx user control. I'm using the below code for reading the pdf file as byte array and then write the byte array to the Response directly.

var pdfBytes = File.ReadAllBytes(filePath);
context.Response.BinaryWrite(pdfBytes);

In case of very large pdf files it's not performing well even though the pdf files were generated with Fast Web View option enabled. Can someone suggest a better solution for this?

Jaganmohanreddy
  • 391
  • 4
  • 19
  • Use TransmitFile instead, though be aware the process is asynchronous so deleting/moving/editing the file afterwards get more involved https://stackoverflow.com/q/2187252/529282 – Martheen Nov 19 '20 at 04:50
  • @Martheen I tried with TransmitFile but in the performance analysis it's still not satisfying as the pdf file size is almost 1GB. – Jaganmohanreddy Nov 19 '20 at 09:08
  • Uh, if you try telling your browser to open that 1 GB file directly, is there a large performance margin compared to opening it through the web app? Maybe open it through an FTP if you want to simulate the network traffic too – Martheen Nov 19 '20 at 09:12
  • Also, explain what's this "performance" analysis means. Unacceptable usage of RAM? CPU? IO? – Martheen Nov 19 '20 at 09:12
  • Maybe Adobe View SDK? https://www.adobe.io/apis/documentcloud/dcsdk/pdf-embed.html – Salik Rafiq Nov 19 '20 at 16:45

0 Answers0