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

432
Views
Download PDF file form embed tag using Puppeteer

I am trying to download a pdf from a Website.

The website is made with the framework ZK, and it reveals a dynamic URL to the PDF for a window of time when an id number type in a input bar. This step is easy enough and I a able to get the PDF URL which opens up in the browser on a embedded tag.

However, it has been impossible for me to find a way to download the file to my computer. For days, I have tried and read everything from this, to this, to this.

The closes thing I have been able to get with this code:

let [ iframe ] = await page.$x('//iframe');
let pdf_url = await page.evaluate( iframe => iframe.src, iframe)

let res = await page.evaluate( async url => 
                await fetch(url, {
                        method: 'GET',
                        credentials: 'same-origin', // usefull when we are logged into a website and want to send cookies
                        responseType: 'arraybuffer', // get response as an ArrayBuffer
                }).then(response => response.text()), 
                pdf_url 
        )
console.log('res:', res);
//const response = await page.goto(pdf);
fs.writeFileSync('somepdf.pdf', res);

This results in a blank PDF file which is of 92K in size.

While the file I am trying to get is of 52K. I suspect the back-end might be sending me 'dummy' pdf file because my headers on the fetch request might not be correct.

What else can I try?

Here is the link to the PDF page.

You can use the random ID number I found: '1705120630'

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!