Click here to Skip to main content
14,599,202 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm trying to get form data from pdf file using PDF.js but got above error.I have downloaded the pdf.js file from Here[^]

What I have tried:

var tmppath = URL.createObjectURL(document.getElementById('flupd').files[0]);
      PDFJS.workerSrc = "js/pdf.worker.js";
      PDFJS.getDocument(tmppath).then(function getPdfHelloWorld(pdf) {
      pdf.getData().then(function (arrayBuffer) {                  
      var pdfraw = String.fromCharCode.apply(null, arrayBuffer);  //getting error here
Updated 14-Mar-17 1:42am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

See Function.prototype.apply() - JavaScript | MDN[^]:
The apply() method calls a function with a given this value and arguments provided as an array.
That means that String.fromCharCode is called with so many arguments as there are items in the array. But there is a limitation for the maximum number of arguments that can be passed to a function (usually about 64k). You have hit this limit which is indicated by the error message.

Use a loop to call String.fromCharCode for each array element or use a text decoder (e.g. TextDecoder("utf-8").decode(arrayBuffer)).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100