Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
PDFTron - ASP.NET C# Byte array to ArrayBuffer or Blob

I am developing an application using PDFTron PDF Viewer library. It allows you to load a PDF in various ways:

https://www.pdftron.com/documentation/web/guides/basics/open/

My ASP.NET controller can most easily return to the view a Byte[] with the PDF contents. My issue is how to do I best use this Byte[] to load the PDFTron Viewer (javascript) in the view? The only way I have managed to do this so far involves converting the Byte[] to a Base64 string and then returning that to view. The view then uses JS code to convert the Base64 string to a Blob using the a function the PDFTron docs suggested:

function base64ToBlob(base64) {
   const binaryString = window.atob(base64);
   const len = binaryString.length;
   const bytes = new Uint8Array(len);
   for (let i = 0; i < len; ++i) {
       bytes[i] = binaryString.charCodeAt(i);
   }

   return new Blob([bytes], { type: 'application/pdf' });
};

Then that Blob can be loaded into the PDFTron viewer. However, this seems to be quite convoluted and slow. Is there a more direct way the PDFTron Viewer could utilise the C# Byte[]? The PDFTron Viewer will accept a Blob or ArrayBuffer but I wasn't sure how best to convert the Byte[] the view receives to either of these types.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!