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