I have to display base64 pdf in new tab. I am using below code
var windo = window.open("", ""); var objbuilder = ''; objbuilder += ('<embed width=\'100%\' height=\'100%\' src="data:application/pdf;base64,'); objbuilder += (fileData); objbuilder += ('" type="application/pdf" />'); windo.document.write(objbuilder);
It is working in FireFox and not working in Chrome and IE. I even tried with tag, but same output, working in FF but not in Chrome and IE.
I look into below JsFiddles, for which are working in FF but not in Chrome,
http://jsfiddle.net/yLx2W/
http://jsfiddle.net/yLx2W/1/
My Chrome version is : Version 54.0.2840.99 m
FireFox Version : 49.0.2
Is any one have any idea, please share.
Thanks in Advance
PDF files contain typically binary data. In XSLT only http://www.w3.org/TR/REC-xml/ s can be processed. This is the reason why you cannot have the PDF file itself in XLST, only its base64 encoding.
To decode a file with contents that are base64 encoded, you simply provide the path of the file with the --decode flag. As with encoding files, the output will be a very long string of the original file. You may want to output stdout directly to a file.
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="data:application/pdf;base64,'); objbuilder += (myBase64string); objbuilder += ('" type="application/pdf" class="internal">'); objbuilder += ('<embed src="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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With