how to display base64 encoded pdf?

for those who still can’t do it, i found this in someone else answer, but i don’t remember who…

var objbuilder="";
objbuilder += ('<object width="100%" height="100%" 
data="https://stackoverflow.com/questions/40674532/data:application/pdf;base64,");
objbuilder += (myBase64string);
objbuilder += ('" type="application/pdf" class="internal">');
objbuilder += ('<embed src="https://stackoverflow.com/questions/40674532/data:application/pdf;base64,");
objbuilder += (myBase64string);
objbuilder += ('" type="application/pdf"  />');
objbuilder += ('</object>');

var win = window.open("#","_blank");
var title = "my tab title";
win.document.write('<html><title>'+ title +'</title><body style="margin-top: 
0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px;">');
win.document.write(objbuilder);
win.document.write('</body></html>');
layer = jQuery(win.document);

this way we open the pdf in a new tab.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)