jsPDF AJAX Tutorial to Encode Uploaded PDF File in PHP Server to Base64 Code in Browser Using Javascript



First, jsPDF is not native in javascript, make sure you have included proper source, and after having a peek on other references, I think you don’t need btoa() function to convert doc.output(), just specify like this :

Second, base-64 encoded string is possible to contain ‘ + ‘ , ‘ / ‘ , ‘ = ‘, they are not URL safe characters , you need to replace them or you cannot deal with ajax .

However, in my own experience, depending on file’s size, it’s easy to be hell long ! before reaching the characters’ length limit of GET method, encoded string will crash your web developer tool first, and debugging would be difficult.

My suggestion, according to your jquery code

It is common setting to send maybe File or Blob object, just have a look on jsPDF, it is availible to convert your data to blob :

so revise your code completely :

and if you are using php on your backend , you could have a look on your data information:

Leave a Reply