Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
Why binary String Data not show as PDF in IFrame?

Here is what I tried

I get some binary string sending a GET request to some API

   let BinaryData = await Operations._sendRequest(baseURL + '/getBinaryString/', 'GET');

above Request give to me like this string

  "%PDF-1.4
%����
4 0 obj
<</Length 5076/Filter/FlateDecode>>stream
x���Kw�F���� Xxa�c� ���\��g��.��E{ ,���-�e����}
................................................................
startxref
5701
%%EOF
"

Firstly I try to encode this string

 const encoder = new TextEncoder()
 let encodeBinaryData = encoder.encode(BinaryData)

Then I convert it to blob

 let blob = new Blob([encodeBinaryData],{type: "application/pdf"});

Finaly I am going to show this data in Iframe

  let frame = document.createElement('iframe');
                    
  frame.src = window.URL.createObjectURL(blob); 

  let par = document.getElementById('pdf');

  par.appendChild(frame);

Now IFrame is empty, It not show the data.Above binary has a table data. I can sent the following responceType to API, But I dont want to use that way

 responceType:"blob" 

if I send the responceType as blob I can get tha data as BLOB and send it to iframe and show as PDF I can see my all data there.

But I want to show the PDF data using above code. I tested if I can show the string in iframe

let str = "Hello World"
let encodeBinaryData = encoder.encode(str)
let blob = new Blob([encodeBinaryData],{type: "text/plain"});

Then I can see correct string there, EX: Hello world

But If I use {type: "application/pdf"} I cant see anything

how Can I fix this problem? (I am using pure HTML)

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda