Js code to open base64 pdf is failing in chrome for pdf of size > 1.5MB

Viewed 109

I have my JS code link.href = 'data:application/pdf;base64,' + data; where data is base64 string which opens properly in firefox but not in chrome when size of pdf file is huge > 1.5MB. Can someone provide solution to handle this issue.

1 Answers

Chrome doesn't allow opening data URLs for security reasons. You might be able to open the link using "Open in new tab" (right click menu).

As a work around, if possible, you can force the user to download the file using <a download="example.pdf" href= data:URL >

Or try using blob:URL instead of data:URL. This might help.

Related