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

134
Views
application/json served from API to frontend save PDF with correct number of pages but no content

After a request to an API, I get a PDF as a response. I then pass this response to the frontend for the user to print, however on the frontend I only manage to get a PDF with the correct number of page, but all the pages are blank.

Here is the request:

const streamResponse = await axios({
    url : endpoint_url,
    method: 'GET',
        headers: {
            some authorization parameters,
        },
        responseType: 'stream'
    });
        
    streamResponse.data.pipe(res)

On the frontend I have this code:

let blob = new Blob([res.data], { type: "application/pdf" });
let link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = 'output.pdf';
link.click();

I also tried to use the file-saver library to directly save the PDF but I get the same result. The data in the response is something like that :

"%PDF-1.4
%����
4 0 obj
<</Filter/FlateDecode/Length 1379>>stream
x���]s�6����3�N�,���%���N����Nn,۴|8|$�_IX a�����$A���WGGΛv>�6�fs̀�#���%d�l����ٿ�ݐ�덦S�L@#&b=$K��>���y�dOd'Y�]��7EV�7X?�h�>`_�
�t%�=��,����!N3Pm,�Ɠ�{�tPYb`������P�jVڭJR����c5�ي��N�$� i�8�Oqlt����wg�#����$�-gC�%��&$Q���q�@���>� �W�i��Ż+TM��s���&uÀk�x$(��|I)8�S^̑�M��y���Na���<)&���hq��D^�̏#HW�G�5~'�M� .......

I know that it is a valid PDF file because I am able to save it on the server, but I cannot find anyway to serve it to the client side.

I also tried to save it in the server and then using a request using the below code to serve it to the client:

let pdfFile = fs.createReadStream(pdfFilePath)
res.setHeader('Content-Type', 'application/pdf')
pdfFile.pipe(res);
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!