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

440
Views
Encoding a remote URL PDF to BASE64 (javascript)

I am trying to encode a PDF that is remotely on a server (not locally neither selecting files using a javascript/HTML "Browse" button) into BASE64.

I already have checked some examples kindly given by others in StackOverflow such as:

Convert PDF to a Base64-encoded string in Javascript

How to convert file to base64 in JavaScript?

But every time I pass the variable where the remote URL for the PDF is, it shows an error saying:

TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'.

function funcTransfPDFParaBase64(strCaminhoPDF) {
var reader = new FileReader();

   reader.readAsDataURL(strCaminhoPDF)
   reader.onload = function () {
     console.log(reader.result);
   };
   reader.onerror = function (error) {
     console.log('Error: ', error);
   };
   
   return reader.result;
}

var objTeste = funcTransfPDFParaBase64(strCaminhoPDF);

URL type used in var strCaminhoPDF: https://somesite/fs/file/Download/FileShare/www/Legislation/2015/DL_2015021028.pdf

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!