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

109
Views
Problem with read file pdf from URL nodeJS

I'm using pdf.js-extract to read data pdf file from URL. This is my code and it runs well:

const fs = require('fs');
const PDFExtract = require('pdf.js-extract').PDFExtract;
const pdfExtract = new PDFExtract();
const https = require('https');

const url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'

const readData = async (url) => {
    https.get(url, async function (response) {
        const file = fs.createWriteStream('./dummy.pdf');
        response.pipe(file);
        file.on("finish", () => {
            pdfExtract.extract('./dummy.pdf', {})
            .then(async function(data) {
                console.log(data)
            });
            file.close();
            fs.unlinkSync('./dummy.pdf')
        });
    });
}

readData(url)

But I have 2 problem about this code.

  1. The first is that how can I deal with if the url changes from https to http, I try node-fetch but it's seem not work as I expected.
  2. The second one is that the code take too long to handle if the pdf file is large, about 5 seconds for 2 Mbs. I wonder if there is a faster way like reading the file from the buffer or something like that without having to save it as a temporary file

Thanks for your attention

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!