In my angular application, I used the below code for convert any file to Base64 string.
handleUpload(event) {
const file = event.target.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => {
console.log(reader.result);
};
}
Here, I want to convert the pdf URL to base64 on the fly. Here's my sample URL which I want to convert base64.
https://vadimdez.github.io/ng2-pdf-viewer/assets/pdf-test.pdf