如何显示base64编码的pdf? [英] how to display base64 encoded pdf?

查看:1069
本文介绍了如何显示base64编码的pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在新标签中显示base64 pdf。我使用下面的代码

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); 

它在FireFox中工作,而不在Chrome和IE中工作。我甚至尝试使用标签,但相同的输出,在FF中工作,但在Chrome和IE中没有。

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.

我查看下面的JsFiddles,其中有FF工作,但没有Chrome,

I look into below JsFiddles, for which are working in FF but not in Chrome,

http://jsfiddle.net/yLx2W/

http://jsfiddle.net/ yLx2W / 1 /

我的Chrome版本为:版本54.0.2840.99 m

My Chrome version is : Version 54.0.2840.99 m

FireFox版本:49.0.2

FireFox Version : 49.0.2

有任何人有任何想法,请分享。

Is any one have any idea, please share.

提前致谢

推荐答案

它可以与Chrome配合使用使用

It should work with Chrome you can use

< iframe src =data:base64 ...>

< object data =data:base64 ...>

我面临与 IE 相同的问题:不可能显示带有 base64 字符串的pdf。

I've faces same issue with IE: it's impossible to display a pdf with a base64 string.

我必须在服务器上生成临时文件,用 IE 显示它们显示现有文件路径。

I had to generate temporary files on the server for display them with IE he only display existing file by using a path.

您仍然可以使用 JS库来显示您的pdf,例如 PDF.js

You still can use JS library to display your pdf like PDF.js.

这篇关于如何显示base64编码的pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆