在Html页面直接展示pdf文件

使用js文件

js文件下载链接:https://github.com/pipwerks/PDFObject/
样例:
在这里插入图片描述
1. Create a container to hold your PDF

<div id="example1"></div>

2. Tell PDFObject which PDF to embed, and where to embed it

<script src="/js/pdfobject.js"></script>
<script>PDFObject.embed("/pdf/sample-3pp.pdf", "#example1");</script>

3. You can optionally use CSS to change the appearance of the containing element, such as height, width, border, margins, etc.

<style>
.pdfobject-container { height: 30rem; border: 1rem solid rgba(0,0,0,.1); }
</style>

不用js文件

Embedding PDFs without using JavaScript

博主使用这种方法显示不出来,可以参考
第一种

<embed src="../pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%">

第二种

<iframe src="../pdf/sample-3pp.pdf#page=2" width="100%" height="100%">
This browser does not support PDFs. Please download the PDF to view it: 
<a href="../pdf/sample-3pp.pdf">Download PDF</a></iframe>

第三种

<object data="../pdf/sample-3pp.pdf#page=2" type="application/pdf" width="100%" height="100%">
<p><b>Example fallback content</b>: This browser does not support PDFs. Please download the PDF to view it: 
<a href="../pdf/sample-3pp.pdf">Download PDF</a>.</p>
</object>

个人微信公众号,专注于学习资源、笔记分享,欢迎关注。我们一起成长,一起学习。一直纯真着,善良着,温情地热爱生活,,如果觉得有点用的话,请不要吝啬你手中点赞的权力,谢谢我亲爱的读者朋友
五角钱的程序员,专注于学习资源、笔记分享。

Maybe sometimes it’s easier to be mad at the people you trust, because you know they’ll always love you, no matter what.
有时候我们更容易对我们相信的人生气,因为你知道不管怎样他们都会永远爱你。

2020年3月31日于重庆城口
好好学习,天天向上,终有所获

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值