-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render Uint8Array throw error #110
Comments
Hi! Have you tried this form the documentation? Closing, but feel free to re-open if this doesn't work. |
In case anyone needs a working version of the process: var binaryImg = atob(base64String);
var binaryImgLength = binaryImg.length;
var arrayBuffer = new ArrayBuffer(binaryImgLength);
var uInt8Array = new Uint8Array(arrayBuffer);
for (var i = 0; i < length; i++) {
uInt8Array[i] = binaryImg.charCodeAt(i);
}
var outputBlob = new Blob([uInt8Array], {type: 'application/pdf'});
$scope.pdfUrl = URL.createObjectURL(outputBlob); |
@johnjspiteri with your code provided above it does creates a pdf but when opened in browser shows no data. |
I would love to help a fellow coder - would need more information. It can be difficult to create an online example... It seems to me that the issue is browser related - can you test FireFox, Chrome and Safari to see if the PDF works on any of those browsers? |
@johnjspiteri You sir are a legend! That solution works brilliantly. I've been searching the interwebs for days looking for a solution to this issue. You'd think being able to generate a downloadable pdf document from a base64 encoded string would be straightforward...but no! This solution needs to be published far and wide to correct a lot of the misinformation out there. Thanks so much for taking the time to post that solution! |
@jjroth you are welcome! Happy that you are getting to where you are going... you inspired me to refactor the answer a little. |
Hi all,
I wan't to render a base64 PDF file with your solution !
I convert base64 to Uint8Array and I try to render it with PDFJS like the following
But when I test it, I see the following warning :
And the following error :
Thanks to your help !
The text was updated successfully, but these errors were encountered: