I have a pdf file rendering correctly when I opened it from acrobat reader, but when I try to open the same pdf(base 64 encoded) in my angular application, it is showing blank pages.
Most of the files are showing as expected. Issue is only with few files which has bad encodings.
So, I would like to know how to fix this encoding issue so that all the pdfs will be rendered correctly in my angular application.
pdf content is coming from the blob which is in base64 encoded format.
that will be downloaded and put that encoded string in a json file.
Json file will be read and the result will be saved as a string like fileReader.result as string(this contains encoded data of pdf as string).
This json will be parsed and assign it to a case object which has an attribute called inputPdf(contains base64 encoded string).
Encoded string will be converted to byteArray and that byteArray is being assigned to pdfsrc.
pdfviewer.pdfsrc = convertedbyteArray
This is working for some of the pdf files but few pdfs are showing blank pages.
Please help to fix this.
I have tried to convert the encoded string to a bytearray like below and assigning it to pdfsrc.
const byteCharacters = atob(base64);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
return byteArray;`