I'm getting my pdf file through URL then save the base64 on a variable, if the file i'm getting is an IMAGE, it works well but if it's PDF, it doesn't work. The data is empty.
function toDataURL(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
console.log(reader.result)
callback(reader.result);
};
reader.readAsDataURL(xhr.response);
};
xhr.open('GET', url);
xhr.responseType = 'blob';
xhr.send();
}