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

209
Views
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
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!