Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda