I have a Base64 string representing a PDF file. I want to convert it to a file with the Blob object using javascript. After it\'s done i want to save the blob as a PDF file
This javascript converts a base64 string to a blob object:
// base64 string
var base64str = result.pdf;
// decode base64 string, remove space for IE compatibility
var binary = atob(base64str.replace(/\s/g, ''));
var len = binary.length;
var buffer = new ArrayBuffer(len);
var view = new Uint8Array(buffer);
for (var i = 0; i < len; i++) {
view[i] = binary.charCodeAt(i);
}
// create the blob object with content-type "application/pdf"
var blob = new Blob( [view], { type: "application/pdf" });
var url = URL.createObjectURL(blob);