在HTML中嵌入PDF的推荐方法是什么?
iFrame吗? 对象? 嵌入?
Adobe是怎么说的呢?
在我的例子中,PDF是动态生成的,因此不能在刷新之前将其上传到第三方解决方案。
在HTML中嵌入PDF的推荐方法是什么?
iFrame吗? 对象? 嵌入?
Adobe是怎么说的呢?
在我的例子中,PDF是动态生成的,因此不能在刷新之前将其上传到第三方解决方案。
当前回答
在我得到嵌入base64编码PDF的问题之前,因为URI限制,所以任何超过2MB的文件都不会在Chrome上正确呈现。
我的解决方案是:
转换uri编码为Blob: 基于Blob生成临时DOM字符串。 const blob = dataURItoBlob(this.dataUrl); var temp_url = window.URL.createObjectURL(blob); 决定你想把iframe附加到DOM的位置: const target = document.querySelector(targetID); 目标。innerHTML =' <iframe src='${temp_url}' type="application/pdf"></iframe> .
其他回答
看看这段代码-将PDF嵌入HTML
<!-- Embed PDF File -->
<object src="YourFile.pdf" type="application/pdf" title="SamplePdf" width="500" height="720">
<a href="YourFile.pdf">shree</a>
</object>
您可以像这样使用保存的pdf的相对位置:
例二
<embed src="example.pdf" width="1000" height="800" frameborder="0" allowfullscreen>
Example2
<iframe src="example.pdf" style="width:1000px; height:800px;" frameborder="0" allowfullscreen></iframe>
在我得到嵌入base64编码PDF的问题之前,因为URI限制,所以任何超过2MB的文件都不会在Chrome上正确呈现。
我的解决方案是:
转换uri编码为Blob: 基于Blob生成临时DOM字符串。 const blob = dataURItoBlob(this.dataUrl); var temp_url = window.URL.createObjectURL(blob); 决定你想把iframe附加到DOM的位置: const target = document.querySelector(targetID); 目标。innerHTML =' <iframe src='${temp_url}' type="application/pdf"></iframe> .
我发现这工作得很好,浏览器处理它在firefox。我没有检查IE…
<script>window.location='url'</script>
Scribd不再要求你把你的文档放在他们的服务器上。如果你和他们一起创建一个账号,你就会得到一个出版商ID。只需要几行JavaScript代码就可以加载存储在您自己服务器上的PDF文件。
有关更多详细信息,请参见开发人员工具。