Render Uint8Array throw error
See original GitHub issueHi 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
function convertDataURIToBinary(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64File);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(var i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
}
var pdfAsDataUri = "data:application/pdf;base64,JVBERi0xLjUN..."; //AWESOME LENGTH
var BASE64_MARKER = ";base64,";
$scope.pdf = convertDataURIToBinary(pdfAsDataUri);
But when I test it, I see the following warning :
Warning: Deprecated API usage: getDocument is called with pdfDataRangeTransport, passwordCallback or progressCallback argument
And the following error :
TypeError: url.charAt is not a function at combineUrl (pdf.js:333)
Thanks to your help !
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
render a Uint8Array pdf throw error · Issue #7070 · mozilla/pdf.js
No description provided. The text was updated successfully, but these errors were encountered: ...
Read more >Javascript: Render PNG stored as Uint8Array ... - Stack Overflow
The proposed solution for turning your Uint8Array to base64 data will throw call stack size errors for large images.
Read more >RangeError: invalid array length - JavaScript - MDN Web Docs
The JavaScript exception "Invalid array length" occurs when specifying an array length that is either negative, a floating number or exceeds ...
Read more >JSDoc: Source: display/api.js
Primarily used to improve performance of font rendering, ... "object") {; throw new Error(; "Invalid parameter in getDocument, " +; "need either Uint8Array, ......
Read more >React Bundle Problem (main[hast].js after build) - JavaScript
_(e))throw new Error("unsupported BodyInit type");this. ... Component { // do stuff } ReactDOM.render(<MyThing>, myElement); </script>.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In case anyone needs a working version of the process:
@jjroth you are welcome! Happy that you are getting to where you are going… you inspired me to refactor the answer a little.