I am not experienced with binary data,
i am using laravel, and my pdf file is in path storage/filename.pdf. when I take the file in the form of binary data, so the response from the backend is in the form of binary data.
i want to output that binary data to pdf viewer on blade, i use jquery ajax.
function showPdf(id, hash){
$.ajax({
url:"{{ route('course-flow-content-pdf') }}",
method:"GET",
data:{id:id, hash:hash},
contentType : 'application/pdf',
responseType : 'arraybuffer',
success:function(result){
console.log(result);
let blob = new Blob([unescape(encodeURIComponent(result))], {
type : "application/pdf"
});
console.log(blob);
let url = URL.createObjectURL(blob)
console.log(url);
}
})
}
I've tried to change it to BLOB. when i debug, it looks like the blob contains proper pdf. but when I generated the url from the blob and displayed it via the URL, the pdf file was blank but the pdf page matched the original file.