I'm new to handling Base64 encoded strings, uint8Array, and Blobs. I've integrated a pdf viewer library from this repository https://github.com/intbot/ng2-pdfjs-viewer into our Angular 8 web application. I'm facing an issue where I am sending a large Base64 string (550KB) that contains 34 pages of text to the UI for rendering by the pdf viewer.
The problem arises when only 19 pages are displayed in the viewer, even though all 34 pages are present when downloading the document using the viewer and checking with the Preview app on MacOS. I'm uncertain whether the problem lies with the pdf viewer library or the conversion process from Base64 to uint8Array/Blob.
Below is the code snippet used in the UI to convert the Base64 string:
dostuff(b64Data){
const byteCharacters = atob(b64Data);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
//const blob = new Blob([byteArray], {type: 'application/pdf'});
//console.log(blob)
return byteArray
}
Any assistance would be highly appreciated. Browser used: Chrome