PDFObject的使用(转)

1.pdfobject.js官网:https://pdfobject.com/

2.在html文件中引入这个文件,以pdfobject.min.js为例

1
< script  type="text/javascript" src="js/pdfobject.min.js"></ script >

 效果1:在指定位置(当指定位置为全局时)浏览PDF,最终效果类似3.1,不做演示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<! DOCTYPE  html>
< html >
     < head >
         < meta  charset="UTF-8">
         < title >在指定div中浏览PDF</ title >
         <!--在此引入bootstrap只为初始化样式div样式-->
         < link  rel="stylesheet" href="css/bootstrap.min.css" />
         < style >
             /* 添加样式是为了实现全屏效果 */
             html,body{
                 height: 100%;
                 overflow: hidden;
             }
             
             #example1{
                 height: 100%;
             }
             
             .pdfobject-container{
                 /* height: 500px; */
             }
             
             .pdfobject{
                 /* border: 1px solid #666; */
             }
         </ style >
     </ head >
     
     < body >
         < div  id="example1"></ div >
             
         < script  type="text/javascript" src="js/pdfobject.min.js"></ script >
         < script >
             // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf
             PDFObject.embed("pdf/Java.pdf", "#example1");
         </ script >
     </ body >
</ html >

  

效果2:在指定位置(当指定位置为局部时)浏览PDF

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<! DOCTYPE  html>
< html >
     < head >
         < meta  charset="UTF-8">
         < title >在指定div中浏览PDF</ title >
         <!--在此引入bootstrap只为初始化样式div样式-->
         < link  rel="stylesheet" href="css/bootstrap.min.css" />
         < style >
             html,body{
                 height: 100%;
                 overflow: hidden;
                 /* 添加背景颜色是为了方便查看整个body范围 */
                
             }
             
             #example1{
                 /* 设置放置PDF的div的样式 */
                 height: 50%;
                 width: 50%;
             }
             
             /* PDF容器样式 */
             .pdfobject-container{
                 /* height: 500px; */
             }
             
             /* PDF样式 */
             .pdfobject{
                 /* border: 1px solid #666; */
             }
         </ style >
     </ head >
     
     < body >
         < div  id="example1"></ div >
             
         < script  type="text/javascript" src="js/pdfobject.min.js"></ script >
         < script >
             // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf
             PDFObject.embed("pdf/Java.pdf", "#example1");
         </ script >
     </ body >
</ html >

  

效果3:指定从多少页开始阅读(必须同时指定显示PDF的div)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<! DOCTYPE  html>
< html >
     < head >
         < meta  charset="UTF-8">
         < title >在指定div中浏览PDF</ title >
         <!--在此引入bootstrap只为初始化样式div样式-->
         < link  rel="stylesheet" href="css/bootstrap.min.css" />
         < style >
             /* 添加样式是为了实现全屏效果 */
             html,body{
                 height: 100%;
                 overflow: hidden;
             }
             
             #example1{
                 height: 100%;
             }
             
             .pdfobject-container{
                 /* height: 500px; */
             }
             
             .pdfobject{
                 /* border: 1px solid #666; */
             }
         </ style >
     </ head >
     
     < body >
         < div  id="example1"></ div >
             
         < script  type="text/javascript" src="js/pdfobject.min.js"></ script >
         < script >
             // 我的pdf文件放在项目的pdf文件夹下,名字叫做Java.pdf,指定PDF从20页开始阅读
             PDFObject.embed("pdf/Java.pdf", "#example1", {page: "20"});
         </ script >
     </ body >
</ html >

  

 

原文地址:https://i.cnblogs.com/EditPosts.aspx?opt=1

转自:https://www.cnblogs.com/liyouwu/p/9722590.html

转载于:https://www.cnblogs.com/miaolyou/p/11150906.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值